Content script can run mutliple times when adding iframes (eg. gmail compose window) |
||
Issue descriptionVersion: 51.0.2704.29 OS: ChromeOS (repros everywhere) What steps will reproduce the problem? (1) Install an extension that injects content scripts into every page (eg. I'm using password alert). (2) Go to gmail (3) Open devtools and put a conditional breakpoint on the first line of the content script with condition "window==window.top". (4) Reply to a message, delete the reply, navigate around a bit What is the expected output? Expect the breakpoint not to be hit. The content script is getting setup inside iframes as they come and go, but shouldn't be running more than once in the main frame. What do you see instead? Breakpoint is hit many times. With password alert in particular, this leads to a new keypress event listener being installed every time (each time is a new closure, so it's not a duplicate listener), eventually leading to terrible keyboard performance problems (see b/27705208). Sounds kinda similar to issue 35924 I haven't tried to reproduce this in a standalone extension yet, but should be trivial. I don't know what's special about the GMail scenario. From the callstack it looks like the content script is being run when an iframe is being added to the document, but simple repros of dynamically adding iframes don't trigger it (http://jsbin.com/namiqoq/2).
,
May 19 2016
I've tried reproducing this with a simple extension too, and haven't been able to repro it yet. I did notice that password alert has some code in the background page to programmatically call chrome.tabs.executeScript - perhaps there's a bug where they're calling that more often than expected (the content script automatically gets injected in all new tabs/frames just from the "content_scripts" manifest entry that matches all urls, so I think they have this code to inject into existing tabs at install time. One possible issue is that on every autoupdate, you'd end up with duplicate copies injected - one from the old version of the extension, and then one from the new copy. But that doesn't seem like it would explain the "additional listener added every time I click" behavior as reported in b/27705208.
,
May 19 2016
Looks like this is actually just a password alert bug afterall (as discussed on b/27705208), sorry! |
||
►
Sign in to add a comment |
||
Comment 1 by rbyers@chromium.org
, May 18 2016