Closed
Bug 1215893
Opened 9 years ago
Closed 9 years ago
Capturing load/DOMContentLoaded/DOMWindowCreated/DocumentElementInserted listeners need to check their targets
Categories
(WebExtensions :: Untriaged, defect)
WebExtensions
Untriaged
Tracking
(firefox44 fixed, firefox45 fixed, b2g-v2.5 fixed)
People
(Reporter: kmag, Assigned: kmag, Mentored)
References
Details
(Whiteboard: [good first bug])
Attachments
(2 files)
8.54 KB,
patch
|
billm
:
review+
ritu
:
approval-mozilla-aurora+
|
Details | Diff | Splinter Review |
8.29 KB,
patch
|
Details | Diff | Splinter Review |
This only happens when using `"backgound": {"scripts": ...` in the manifest. It presumably also happens for any other element which emits load events (images). If the element in question is injected by one of those background scripts, it results in an infinite loop.
Hey i would like to work on this bug !! Can u please help me how to go about it
Assignee | ||
Comment 2•9 years ago
|
||
(In reply to Shivam from comment #1) > Hey i would like to work on this bug !! Can u please help me how to go about > it Certainly. You should start by checking out the source code for Firefox, and making sure you can build it, if you haven't done it before: https://developer.mozilla.org/en-US/docs/Simple_Firefox_build The code that loads the background scripts is here: https://dxr.mozilla.org/mozilla-central/source/toolkit/components/extensions/ext-backgroundPage.js If you have any questions, feel free to ask here or in irc://irc.mozilla.org/webextensions
Updated•9 years ago
|
Flags: blocking-webextensions+
Assignee | ||
Comment 3•9 years ago
|
||
I'm just going to retarget this bug, since we do this in several places.
Summary: Adding an iframe to a background page causes background scripts to be re-loaded → Capturing load/DOMContentLoaded/DOMWindowCreated/DocumentElementInserted listeners need to check their targets
Assignee | ||
Comment 4•9 years ago
|
||
This fixes the issues with events being processed for the wrong targets. I'm worried that some of these event handlers are still a bit shaky, though. The "unload" handler in Extension.jsm, for instance, definitely does not fire for pages that end up in bfcache. And I'm pretty sure we still handle some events even if the docshell navigates to a new page before they've fired.
Attachment #8687636 -
Flags: review?(wmccloskey)
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → kmaglione+bmo
Status: NEW → ASSIGNED
Comment on attachment 8687636 [details] [diff] [review] [webext] Check capturing event listeners for the correct target Review of attachment 8687636 [details] [diff] [review]: ----------------------------------------------------------------- ::: toolkit/components/extensions/Extension.jsm @@ +321,5 @@ > inject(extension, context); > > let eventHandler = docShell.chromeEventHandler; > let listener = event => { > + if ((event.target.defaultView.QueryInterface(Ci.nsIInterfaceRequestor) I think you can check event.target against docShell.contentViewer.DOMDocument. That's a little shorter. ::: toolkit/components/extensions/ExtensionContent.jsm @@ +332,5 @@ > handleEvent: function(event) { > + let window = event.currentTarget; > + if (event.target != window.document) { > + // We use capturing listeners so we have precendence over content script > + // listeners, but only care about events targetted to the element we're targeted?
Attachment #8687636 -
Flags: review?(wmccloskey) → review+
Assignee | ||
Comment 6•9 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/8e712e56faf8ef12537ad604f38bca4f06665a7b Bug 1215893: [webext] Check capturing event listeners for the correct target. r=billm
Comment 7•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/8e712e56faf8
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox45:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Assignee | ||
Comment 8•9 years ago
|
||
Comment on attachment 8687636 [details] [diff] [review] [webext] Check capturing event listeners for the correct target Approval Request Comment [Feature/regressing bug #]: Bug 1175770 [User impact if declined]: Without this fix, attempting to load an <iframe>, and <img>, or anything else which fires a "load" event, in a background page causes an infinite loop, which makes the browser UI unresponsive and is difficult to break, even with a browser restart. Given the current attention WebExtensions are receiving on Developer Edition, and the number of use cases for loading content into background pages this way, this is likely to be encountered by many developers, and give a negative impression of the stability of the framework. [Describe test coverage new/current, TreeHerder]: The tests for the background page API this most directly affects, and the panel APIs which it touches, are fairly extensive, and the patch adds sufficient additional tests to ensure that the fix is effective. [Risks and why]: Low. This patch only affects the WebExtensions API, which developers should be aware is in a pre-release state. The changes are fairly minor, and well-tested, so the chance for regression is minimal. [String/UUID change made/needed]: None.
Attachment #8687636 -
Flags: approval-mozilla-aurora?
Comment on attachment 8687636 [details] [diff] [review] [webext] Check capturing event listeners for the correct target Been in Nightly for 10 days and impacts WebExtensions in DevEdition, taking it for Aurora44.
Attachment #8687636 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
status-firefox44:
--- → affected
Updated•9 years ago
|
Iteration: --- → 45.2 - Nov 30
Comment 10•9 years ago
|
||
has problems during uplift grafting 315364:8e712e56faf8 "Bug 1215893: [webext] Check capturing event listeners for the correct target. r=billm" merging browser/components/extensions/ext-utils.js merging toolkit/components/extensions/Extension.jsm merging toolkit/components/extensions/ExtensionContent.jsm merging toolkit/components/extensions/test/mochitest/mochitest.ini warning: conflicts while merging browser/components/extensions/ext-utils.js! (edit, then use 'hg resolve --mark') warning: conflicts while merging toolkit/components/extensions/test/mochitest/mochitest.ini! (edit, then use 'hg resolve --mark')
Flags: needinfo?(kmaglione+bmo)
Assignee | ||
Comment 11•9 years ago
|
||
Flags: needinfo?(kmaglione+bmo)
Assignee | ||
Comment 12•9 years ago
|
||
https://hg.mozilla.org/releases/mozilla-aurora/rev/bf8a7ca8ccdb
Comment 13•9 years ago
|
||
bugherder uplift |
https://hg.mozilla.org/releases/mozilla-b2g44_v2_5/rev/bf8a7ca8ccdb
status-b2g-v2.5:
--- → fixed
Updated•6 years ago
|
Product: Toolkit → WebExtensions
You need to log in
before you can comment on or make changes to this bug.
Description
•