Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 "use strict"; | 1 "use strict"; |
2 | 2 |
3 (function() | 3 (function() |
4 { | 4 { |
5 if ((typeof chrome == "undefined") || | 5 if (typeof chrome == "undefined" || typeof chrome.extension == "undefined") |
6 (typeof chrome.extension == "undefined")) | 6 window.chrome = browser; |
Sebastian Noack
2017/06/07 14:42:14
Why is explicit checking for chrome.extension nece
Oleksandr
2017/06/14 03:41:01
There is a 'chrome' object defined in Edge, which
Sebastian Noack
2017/06/14 05:13:38
That's why we only check for `typeof chrome.extens
| |
7 chrome = browser; | |
Sebastian Noack
2017/06/07 14:42:14
Is this variable meant to be global? If so, we sho
Oleksandr
2017/06/14 03:41:01
Done.
| |
8 const backgroundPage = chrome.extension.getBackgroundPage(); | 7 const backgroundPage = chrome.extension.getBackgroundPage(); |
9 window.ext = Object.create(backgroundPage.ext); | 8 window.ext = Object.create(backgroundPage.ext); |
10 | 9 |
11 window.ext.closePopup = () => | 10 window.ext.closePopup = () => |
12 { | 11 { |
13 window.close(); | 12 window.close(); |
14 }; | 13 }; |
14 | |
15 // Calling i18n.getMessage from the background page causes Edge to throw an | |
16 // exception. | |
17 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/127939 75/ | |
18 window.ext.i18n = chrome.i18n; | |
15 | 19 |
16 // We have to override ext.backgroundPage, because in order | 20 // We have to override ext.backgroundPage, because in order |
17 // to send messages the local "chrome" namespace must be used. | 21 // to send messages the local "chrome" namespace must be used. |
18 window.ext.backgroundPage = { | 22 window.ext.backgroundPage = { |
19 sendMessage: chrome.runtime.sendMessage, | 23 sendMessage: chrome.runtime.sendMessage, |
20 | 24 |
21 getWindow() | 25 getWindow() |
22 { | 26 { |
23 return backgroundPage; | 27 return backgroundPage; |
24 } | 28 } |
25 }; | 29 }; |
26 }()); | 30 }()); |
LEFT | RIGHT |