Closed
Bug 1514673
Opened 6 years ago
Closed 6 years ago
A promise chain failed to handle a rejection: Argument 1 of WebExtensionPolicy.canAccessWindow is not an object. - stack: canAccessWindow@resource://gre/modules/Extension.jsm:1608:12 after bug 1498775
Categories
(WebExtensions :: General, defect)
WebExtensions
General
Tracking
(firefox66 verified, firefox67 verified)
VERIFIED
FIXED
mozilla66
People
(Reporter: arai, Assigned: mixedpuppy)
References
Details
Attachments
(1 file, 1 obsolete file)
(deleted),
text/x-phabricator-request
|
Details |
After fixing bug 1498775, the following error happens:
https://treeherder.mozilla.org/#/jobs?repo=mozilla-inbound&resultStatus=testfailed%2Cbusted%2Cexception%2Crunnable&classifiedState=unclassified&revision=d3058a4b2450317636a81badc374600e913940c0&selectedJob=217378267
TEST-UNEXPECTED-FAIL | toolkit/components/extensions/test/browser/browser_ext_themes_dynamic_getCurrent.js | A promise chain failed to handle a rejection: Argument 1 of WebExtensionPolicy.canAccessWindow is not an object. - stack: canAccessWindow@resource://gre/modules/Extension.jsm:1608:12
canAccessWindow@resource://gre/modules/ExtensionCommon.jsm:453:12
getAPI/register/listener/<@chrome://browser/content/parent/ext-windows.js:76:22
https://searchfox.org/mozilla-central/rev/1a4a7745fd4a14402a0de0e9abc040724d4fcf8f/toolkit/components/extensions/Extension.jsm#1608
> class Extension extends ExtensionData {
> ...
> canAccessWindow(window) {
> return this.policy.canAccessWindow(window);
> }
https://searchfox.org/mozilla-central/rev/1a4a7745fd4a14402a0de0e9abc040724d4fcf8f/toolkit/components/extensions/ExtensionCommon.jsm#453
> class BaseContext {
> ...
> canAccessWindow(window) {
> return this.extension.canAccessWindow(window);
> }
https://searchfox.org/mozilla-central/rev/1a4a7745fd4a14402a0de0e9abc040724d4fcf8f/browser/components/extensions/parent/ext-windows.js#76
> this.windows = class extends ExtensionAPI {
> getAPI(context) {
> let {extension} = context;
>
> const {windowManager} = extension;
>
> return {
> windows: {
> ...
> onFocusChanged: new EventManager({
> context,
> name: "windows.onFocusChanged",
> register: fire => {
> // Keep track of the last windowId used to fire an onFocusChanged event
> let lastOnFocusChangedWindowId;
>
> let listener = event => {
> // Wait a tick to avoid firing a superfluous WINDOW_ID_NONE
> // event when switching focus between two Firefox windows.
> Promise.resolve().then(() => {
> let window = Services.focus.activeWindow;
> if (!context.canAccessWindow(window)) {
possibly the activeWindow property is either null or undefined.
Reporter | ||
Comment 1•6 years ago
|
||
https://searchfox.org/mozilla-central/rev/1a4a7745fd4a14402a0de0e9abc040724d4fcf8f/browser/components/extensions/parent/ext-windows.js#74-84
> Promise.resolve().then(() => {
> let window = Services.focus.activeWindow;
> if (!context.canAccessWindow(window)) {
> return;
> }
> let windowId = window ? windowTracker.getId(window) : Window.WINDOW_ID_NONE;
> if (windowId !== lastOnFocusChangedWindowId) {
> fire.async(windowId);
> lastOnFocusChangedWindowId = windowId;
> }
> });
The issue is that, the return value of `Promise.resolve().then(...)` is not used, which results in not-reporting the unhandled rejection (which is going to be fixed by bug 1498775).
Given the next line after `context.canAccessWindow` call checks the if `window` is falsy,
falsy `window` seems to be expected.
`context.canAccessWindow` call should be skipped in that case I guess.
Reporter | ||
Comment 2•6 years ago
|
||
I'll post a patch after some test
Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
Assignee | ||
Comment 3•6 years ago
|
||
Assignee | ||
Comment 4•6 years ago
|
||
Tooru, sorry, I worked up a patch before I realized you actually took the bug. Since I made the patch already, I'm taking over the bug.
Assignee: arai.unmht → mixedpuppy
Assignee | ||
Comment 5•6 years ago
|
||
Assignee | ||
Comment 6•6 years ago
|
||
Assignee | ||
Comment 7•6 years ago
|
||
Tooru can you take a peak at the try in comment 6?
Flags: needinfo?(arai.unmht)
Reporter | ||
Comment 8•6 years ago
|
||
looks like, bug 1514699 (bc* failures) is not from bug 1498775 change, but just that it's discovered by this change?
I filed bug 1514699 after my WIP patch for this bug applied, and got the same error:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=6ae720e277c240352adf7670c048743c768ae149&selectedJob=217387043
also, I saw the similar error to dt4, not yet figured out if it's pre-existing tho
https://treeherder.mozilla.org/#/jobs?repo=mozilla-inbound&revision=d3058a4b2450317636a81badc374600e913940c0&duplicate_jobs=visible&searchStr=dt&selectedJob=217380038
Reporter | ||
Updated•6 years ago
|
Pushed by mixedpuppy@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/6267aad872ec
allow WINDOW_ID_NONE in focus listener, r=rpl
Comment 10•6 years ago
|
||
Backed out changeset 6267aad872ec (Bug 1514673) for bc failures in browser/components/extensions/test/browser/test-oop-extensions/browser_ext_tabs_events.js
https://treeherder.mozilla.org/#/jobs?repo=autoland&selectedJob=217710655
https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=217710655&repo=autoland&lineNumber=2563
Comment 11•6 years ago
|
||
Backout by shindli@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/cd6b203426db
Backed out changeset 6267aad872ec for bc failures in browser/components/extensions/test/browser/test-oop-extensions/browser_ext_tabs_events.js
Assignee | ||
Comment 12•6 years ago
|
||
Updated•6 years ago
|
Attachment #9031879 -
Attachment is obsolete: true
Comment 13•6 years ago
|
||
Pushed by mixedpuppy@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/d0f2ead4061c
allow WINDOW_ID_NONE in focus listener, r=rpl
Comment 14•6 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
status-firefox66:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla66
Reporter | ||
Updated•6 years ago
|
Flags: needinfo?(arai.unmht)
Comment 16•6 years ago
|
||
Verified as fixed on latest FF66 and FF67 using the following steps(Thanks @rpl for the steps):
- toggle incognito mode preference by flipping "extensions.allowPrivateBrowsingByDefault" to false
- install the test extension from https://drive.google.com/file/d/1ZM3Qo4ltc1i5dqsEDPzwQon3iTPOFiXT/view?usp=sharing
- open the browser console and a private window
- open another unrelated application (e.g. a text editor)
- focus the initial firefox window and then the browser console (a couple of console messages "Received windowId ..., is it WINDOW_ID_NONDE? true/false" should be logged, and no "Argument 1 of WebExtensionPolicy.canAccessWindow is not an object." error)
- focus the initial firefox window and then the private window (same messages as above, and not the error message)
- focus the initial firefox window and then the unrelated application (e.g. the text editor, same messages as above and not the error message)
Status: RESOLVED → VERIFIED
Updated•6 years ago
|
status-firefox67:
--- → verified
You need to log in
before you can comment on or make changes to this bug.
Description
•