Descriptionextensions: Fix synchronization in ContentScriptApiTest.ContentScriptOtherExtensions
The ContentScriptApiTest.ContentScriptOtherExtensions has the following
flow:
1. Register the inject.js content script to run at 'document_end'
time.
2. Load iframe_content.{html,js} in an iframe.
3. On DOMContentLoaded, set a 10ms timer to report the iframe's contents
to the test harness.
4. In 'inject.js', rewrite the page's content.
5. In the test harness, verify that the page reports the content mutated
by inject.js.
The problem is that the timer registered in step 3 races with the
task[1] triggering the injection script since there's no explicit
synchronization between the two. Currently this works by accident, but
an upcoming change[2] in the Blink Scheduler will cause the test to
actually become flaky.
This change fixes the test by making the iframe report its contents
based on the load event rather than DOMContentLoaded. Since this is
guaranteed to happen after the injection has finished, there's no
possibility of out-of-order execution.
BUG=696001, 701223
[1] blink::FrameLoader::finishedParsing
=> extensions::ScriptInjection::InjectJs
=> blink::SuspendableScriptExecutor::create
[2] https://bugs.chromium.org/p/chromium/issues/detail?id=701223#c4
Review-Url: https://codereview.chromium.org/2800103002
Cr-Commit-Position: refs/heads/master@{#463294}
Committed: https://chromium.googlesource.com/chromium/src/+/7d68ce72674bc9189bd8bcf305823d75c044489d
Patch Set 1 #Patch Set 2 : Fix typo (document => window) #Messages
Total messages: 17 (13 generated)
|