|
|
Split content script injections into multiple tasks
Currently, content scripts for all extensions are injected in single
task, causing a big jank on main thread. This patch changes
document_end and document_idle content scripts to run in separate tasks
asynchronously. The window.onload event is blocked until all
document_end scripts are injected.
This new behavior is protected by a feature switch, disabled by default.
To enable asynchronous execution, this CL adds a option parameter to
WebLocalFrame::requestExecuteScriptInIsolatedWorld(). Inside Blink,
it uses SuspendableScriptExecutor's ability to delay execution. So
async script executions are posted as timer tasks.
To test the new behavior, browser tests in content_script_apitest.cc
are parameterized so they run with and without the flag enabled.
Also, some extensions for tests are switched from document_idle to
document_end, since after this patch there's no reliable way to make
sure that all document_idle scripts have finished.
BUG= 636655
Review-Url: https://codereview.chromium.org/2633253002
Cr-Commit-Position: refs/heads/master@{#457702}
Committed: https://chromium.googlesource.com/chromium/src/+/cbf167aaccb8c6f17c305dffa76b6523776222bf
Total comments: 12
Total comments: 8
Total comments: 21
Total comments: 6
Total comments: 2
Total comments: 7
|
Unified diffs |
Side-by-side diffs |
Delta from patch set |
Stats (+310 lines, -55 lines) |
Patch |
 |
M |
chrome/browser/chrome_content_browser_client.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
 |
M |
chrome/browser/extensions/content_script_apitest.cc
|
View
|
1
2
3
4
5
6
7
8
|
15 chunks |
+57 lines, -23 lines |
0 comments
|
Download
|
 |
M |
chrome/renderer/chrome_content_renderer_client.h
|
View
|
1
2
3
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
 |
M |
chrome/renderer/chrome_content_renderer_client.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+9 lines, -0 lines |
0 comments
|
Download
|
 |
M |
chrome/renderer/extensions/chrome_extensions_renderer_client.h
|
View
|
1
2
3
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
 |
M |
chrome/renderer/extensions/chrome_extensions_renderer_client.cc
|
View
|
1
2
3
|
1 chunk |
+5 lines, -0 lines |
0 comments
|
Download
|
 |
M |
chrome/test/data/extensions/api_test/content_scripts/about_blank_iframes/test.js
|
View
|
1
2
3
4
5
6
7
8
|
1 chunk |
+3 lines, -1 line |
0 comments
|
Download
|
 |
M |
chrome/test/data/extensions/platform_apps/web_view/content_script_whitelisted/main.js
|
View
|
1
2
3
4
5
6
|
1 chunk |
+1 line, -1 line |
0 comments
|
Download
|
 |
M |
content/public/renderer/content_renderer_client.h
|
View
|
1
2
3
4
|
1 chunk |
+4 lines, -0 lines |
0 comments
|
Download
|
 |
M |
content/renderer/render_frame_impl.h
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
 |
M |
content/renderer/render_frame_impl.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
2 chunks |
+8 lines, -2 lines |
0 comments
|
Download
|
 |
M |
extensions/common/feature_switch.h
|
View
|
1
2
3
4
5
6
7
8
|
3 chunks |
+4 lines, -0 lines |
0 comments
|
Download
|
 |
M |
extensions/common/feature_switch.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
5 chunks |
+17 lines, -1 line |
0 comments
|
Download
|
 |
M |
extensions/common/switches.h
|
View
|
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
 |
M |
extensions/common/switches.cc
|
View
|
|
1 chunk |
+4 lines, -0 lines |
0 comments
|
Download
|
 |
M |
extensions/renderer/dispatcher.h
|
View
|
1
2
3
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
 |
M |
extensions/renderer/dispatcher.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+9 lines, -0 lines |
0 comments
|
Download
|
 |
M |
extensions/renderer/extension_frame_helper.h
|
View
|
1
2
3
|
3 chunks |
+9 lines, -0 lines |
0 comments
|
Download
|
 |
M |
extensions/renderer/extension_frame_helper.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
|
2 chunks |
+11 lines, -0 lines |
0 comments
|
Download
|
 |
M |
extensions/renderer/script_injection.h
|
View
|
|
2 chunks |
+4 lines, -3 lines |
0 comments
|
Download
|
 |
M |
extensions/renderer/script_injection.cc
|
View
|
1
2
3
4
5
6
7
8
9
10
11
|
6 chunks |
+49 lines, -8 lines |
0 comments
|
Download
|
 |
M |
extensions/renderer/script_injection_manager.cc
|
View
|
1
2
3
4
5
6
7
8
|
2 chunks |
+14 lines, -5 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/core/frame/LocalFrameClient.h
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/core/loader/EmptyClients.h
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/core/loader/FrameLoader.cpp
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+13 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/LocalFrameClientImpl.h
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/LocalFrameClientImpl.cpp
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+6 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/SuspendableScriptExecutor.h
|
View
|
1
2
3
4
5
6
7
8
9
|
3 chunks |
+11 lines, -6 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp
|
View
|
1
2
3
4
5
6
7
8
9
10
|
5 chunks |
+20 lines, -3 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/WebLocalFrameImpl.h
|
View
|
1
2
3
4
5
6
7
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
|
View
|
1
2
3
4
5
6
7
8
9
10
|
2 chunks |
+15 lines, -2 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/web/WebFrameClient.h
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+4 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/web/WebLocalFrame.h
|
View
|
1
2
3
4
5
6
7
|
2 chunks |
+10 lines, -0 lines |
0 comments
|
Download
|
 |
M |
third_party/WebKit/public/web/WebScriptExecutionCallback.h
|
View
|
|
1 chunk |
+3 lines, -0 lines |
0 comments
|
Download
|
 |
M |
tools/metrics/histograms/histograms.xml
|
View
|
1
2
3
4
5
6
7
8
9
10
|
1 chunk |
+10 lines, -0 lines |
0 comments
|
Download
|
Total messages: 118 (84 generated)
|