Check for valid Navigator.permissions before use

Safari on iOS now supports the Navigator.clipboard
API, but not the Navigator.permissions API.

Looks like we have not encountered this combination
Before. Add undefined check for permissions as well.

Fixes: QTBUG-84658
Pick-to: 5.15
Change-Id: I99ab08fd34bbb29a82661e24bf400c927f3604f6
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This commit is contained in:
Morten Johan Sørvig 2020-06-05 18:07:15 +02:00
parent ac419a66fd
commit 974f239338

View File

@ -126,8 +126,9 @@ EMSCRIPTEN_BINDINGS(qtClipboardModule) {
QWasmClipboard::QWasmClipboard()
{
val clipboard = val::global("navigator")["clipboard"];
hasClipboardApi = (!clipboard.isUndefined() && !clipboard["readText"].isUndefined());
val permissions = val::global("navigator")["permissions"];
hasClipboardApi = (!clipboard.isUndefined() && !permissions.isUndefined() && !clipboard["readText"].isUndefined());
if (hasClipboardApi)
initClipboardEvents();
}