Greasemonkey: webkit: Don't use Object.entries in js.

Apparently the currently available QtWebkit's javascript engine doesn't
support Object.entries[1]. It was only using that because I had copied
it from the official gm4 polyfill (maybe I should open an issue there?).

Tested with libqt5webkit5 version 5.212.0~alpha2-5 (debian) and I was
getting the same type of failures as Travis so it looks like this is the
case in arch too.

[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries
This commit is contained in:
Jimmy 2018-01-05 20:45:32 +13:00
parent 919fe45813
commit 60e6d28eb1

View File

@ -123,7 +123,7 @@
// Mock the greasemonkey 4.0 async API.
const GM = {};
GM.info = GM_info;
Object.entries({
const entries = {
'log': GM_log,
'addStyle': GM_addStyle,
'deleteValue': GM_deleteValue,
@ -132,7 +132,9 @@
'openInTab': GM_openInTab,
'setValue': GM_setValue,
'xmlHttpRequest': GM_xmlhttpRequest,
}).forEach(([newKey, old]) => {
}
for (newKey in entries) {
let old = entries[newKey];
if (old && (typeof GM[newKey] == 'undefined')) {
GM[newKey] = function(...args) {
return new Promise((resolve, reject) => {
@ -144,7 +146,7 @@
});
};
}
});
};
const unsafeWindow = window;