New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 695544 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

<webview> documentation is unclear on execute/injectScript vs. navigation

Project Member Reported by mfo...@chromium.org, Feb 23 2017

Issue description

The documentation for <webview> is unclear on when executeScript can be called and how it relates to navigation.

https://developer.chrome.com/apps/tags/webview#method-executeScript

Context: We wish to inject a polyfill into a <webview> before any document-provided script executes.

jrw@ reports that calling it before webview.load fires results in an error.  Calling it in webview.load may work - is the Document created yet?  Calling it in webview.contentload may be too late for us (has document script execution begun yet)?

As a workaround jrw@ is using a content script injected on document_start and MutationObserver to insert a <script> immediately after <head> is created.  This is an ugly hack that could be avoided with executeScript.

In short, the behavior of webview.executeScript needs to be documented:

1. Before load.
2. In the load handler.
3. After load fires and before contentload does.
4. In the contentload handler.
5. After contentload fires.

And content script injection points (document_start, document_idle, document_end) need to also be included in that sequence.





 
The webview.executeScript API is kind of broken. There are no injection time guarantees across navigations. I suggested using addContentScripts. https://developer.chrome.com/apps/tags/webview#method-addContentScripts
Owner: wjmaclean@chromium.org
Status: Assigned (was: Untriaged)
Assigning to wjmaclean for webview triage.

Sign in to add a comment