New issue
Advanced search Search tips

Issue 598896 link

Starred by 6 users

Issue metadata

Status: Duplicate
Merged: issue 478183
Owner: ----
Closed: Apr 2016
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Need a reliable way to make chrome.tabs.executeScript run code at document_start

Reported by derj...@googlemail.com, Mar 29 2016

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/49.0.2623.87 Chrome/49.0.2623.87 Safari/537.36

Steps to reproduce the problem:
1. install the attached CRX
2. open:
  * http://test.tampermonkey.net/es.html
  * http://test.tampermonkey.net/es_extscript.html
3. See that at both pages (please reload many times):
 * "onHeadersReceived" is never logged
 * all other background events are sometimes or always logged after "page"
 * "onResponseStarted" sometimes isn't logged at all

What is the expected behavior?
It should be possible to schedule code via executeScript at the onHeadersReceived listener, because this is the last blocking webRequest listener that allows background scripts to do some things that need to be done before the page loads. 

I'd also prefer to schedule executeScript triggered code before the manifest content_scripts (before is preferred, cause content_scripts are less flexible but could be parameterized by executeScript).

Note: "content_script" is always logged before "page", which is the desired behavior for executeScript-injected code as well.

What went wrong?
There is no reliable way to make executeScript run (lengthy) code before the page scripts.

WebStore page: https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo

Did this work before? N/A 

Chrome version: 50.0.2661.18  Channel: n/a
OS Version: 
Flash Version: 

There is issue 471801 which might be related, but is a different issue cause it requests an argument to inject code via chrome.tabs.update. However, if executeScript would be more reliable that issue might be work-arounded in simlar way.

In combination with  issue 63979  this change would be used at the Tampermonkey extension (5.7 million users) to replace manifest-based content-scripts in long-term and inject the user scripts + environment only at pages where a user script is supposed to run at. In short-term it simplifies the content scripts to not to unnecessary things in case no script is supposed to run.

Thanks.
 
executeScriptBug.crx
32.4 KB Download

Comment 1 by kolos@chromium.org, Apr 5 2016

Components: Privacy

Comment 2 by rob@robwu.nl, Apr 28 2016

Mergedinto: 478183
Status: Duplicate (was: Unconfirmed)

Sign in to add a comment