Revert of Always preload all tokens before parsing (https://codereview.chromium.org/302063002/)

Reason for revert:
This change breaks:
org.chromium.android_webview.test.AwSettingsTest#testBlockNetworkImagesDoesNotBlockDataUrlImage

Probably because it pre-loads images when "automatically load images" is disabled on Android.

See
http://build.chromium.org/p/tryserver.chromium/builders/android_dbg_triggered_tests/builds/159696/steps/androidwebview_instrumentation_tests/logs/stdio

Original issue's description:
> Always preload all tokens before parsing
> 
> This change is in preparation for re-writing the path
> through which tokens are handled on the main thread
> to allow them to be batched and deferred until more
> important work is done:
> https://codereview.chromium.org/258013009/
> 
> Currently the threaded parser uses the main thread's
> MessageQueue as its work-queue and we'll commonly
> queue 10 chunks of work in the main thread MessageQueue
> even if the first chunk takes a long time we'll still have to
> process the next 9 before we can do more important things
> like put up a frame because we don't have a separate
> queue for parser work.  258013009 will fix that.
> 
> http/tests/security/script-crossorigin-loads-correctly-credentials-2.html
> originally started failing with this change and it
> turns out that always-preloading found a real bug
> in CORS handling with preloads. The ResourceFetcher
> was incorrectly always reusing an in-flight preload
> request, even if the CORS state didn't match. Nate
> helped me re-order the calls in requestResource to fix it.
> 
> This change also discovered 2 other bugs in the preloader.
> 1. a preload request != LinkPrefect request
> and one will cancel the other. crbug.com/379893
> 2. The preloader has no concept of script type and will
> blindly issue preloads for all <script href> regardless
> of <script type>.  I decided this didn't matter in practice.
> Making the <script type> handling threadsafe isn't
> worth the trouble.
> 
> I would anticipate that this change might make some
> speed-index scores better (we'll now be preloading
> all tokens slightly sooner, especially those
> which are in the same chunk as a long inline
> script block for instance), but may make non-network
> PLT scores lower (due to extra mallocs required
> to process every chunk since more loads will
> be preloaded just before their actually loaded).
> 
> BUG=356292
> 
> Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=175427

TBR=tonyg@chromium.org,japhet@chromium.org,eseidel@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=356292

Review URL: https://codereview.chromium.org/317703005

git-svn-id: svn://svn.chromium.org/blink/trunk@175512 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 142fb4cd
nick.jpg has MIME type image/jpeg nick.jpg has MIME type image/jpeg
nick.jpg has MIME type image/jpeg nick.jpg has MIME type image/jpeg
nick.jpg has MIME type image/jpeg
This test verifies that an image which is prefetched, and which is also contained as a subresource of the current document can be loaded correctly as a subresource. See bug 49236 in which this wasn't working. This test verifies that an image which is prefetched, and which is also contained as a subresource of the current document can be loaded correctly as a subresource. See bug 49236 in which this wasn't working.
When this test succeeds, you'll see an image of Nick on a sailboat immediately below this text. When this test fails, you will see no images at all. When this test succeeds, you'll see an image of Nick on a sailboat immediately below this text. When this test fails, you will see no images at all.
This test shows 3 loads of nick.jpg even though from the source it looks like there should only be 2. crbug.com/379893
NICK_ONLOAD called NICK_ONLOAD called
NICK_ONLOAD called NICK_ONLOAD called
......
...@@ -31,8 +31,6 @@ subresource of the current document can be loaded correctly as a subresource. S ...@@ -31,8 +31,6 @@ subresource of the current document can be loaded correctly as a subresource. S
bug 49236 in which this wasn't working. bug 49236 in which this wasn't working.
<p>When this test succeeds, you'll see an image of Nick on a sailboat immediately below <p>When this test succeeds, you'll see an image of Nick on a sailboat immediately below
this text. When this test fails, you will see no images at all. this text. When this test fails, you will see no images at all.
<p>This test shows 3 loads of nick.jpg even though from the source it looks like there
should only be 2. crbug.com/379893
<link rel="prefetch" href="resources/nick.jpg" onload="nick_onload()" /> <link rel="prefetch" href="resources/nick.jpg" onload="nick_onload()" />
<img src="resources/nick.jpg" onload="nick_onload()" /> <img src="resources/nick.jpg" onload="nick_onload()" />
<hr> <hr>
......
shouldnotexecute.js has MIME type application/javascript Unknown script types should not be loaded nor executed. If this test fails, an extra line will appear in the output with the script's MIME type.
Unknown script types should not be loaded nor executed. If this test fails, an more than one line will appear in the output with the script's MIME type. One line is OK, as it's from the prelaoder (which has no concept of invalid script types and will happily issue a preload).
...@@ -17,4 +17,4 @@ ...@@ -17,4 +17,4 @@
document.getElementsByTagName("head")[0].appendChild(bogus_script); document.getElementsByTagName("head")[0].appendChild(bogus_script);
</script> </script>
<script type="fake" src="shouldnotexecute.js"></script> <script type="fake" src="shouldnotexecute.js"></script>
Unknown script types should not be loaded nor executed. If this test fails, an more than one line will appear in the output with the script's MIME type. One line is OK, as it's from the prelaoder (which has no concept of invalid script types and will happily issue a preload). Unknown script types should not be loaded nor executed. If this test fails, an extra line will appear in the output with the script's MIME type.
...@@ -27,8 +27,7 @@ function setUpTest() ...@@ -27,8 +27,7 @@ function setUpTest()
window.jsTestIsAsync = true; window.jsTestIsAsync = true;
iframe = document.getElementById('scrollable'); iframe = document.getElementById('scrollable');
// iframes start in readyState complete, but with the about:blank doc, make sure our doc is loaded. if (iframe.contentDocument.readyState != "complete")
if (iframe.src != iframe.contentDocument.URL || iframe.contentDocument.readyState != "complete")
iframe.onload = testIt; iframe.onload = testIt;
else else
testIt(); testIt();
......
CONSOLE WARNING: line 1: The page at 'https://127.0.0.1:8443/security/contentSecurityPolicy/resources/mixed-content-with-csp.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/contentSecurityPolicy/resources/alert-fail.js': this content should also be loaded over HTTPS.
CONSOLE ERROR: Refused to load the script 'http://127.0.0.1:8080/security/contentSecurityPolicy/resources/alert-fail.js' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback. CONSOLE ERROR: Refused to load the script 'http://127.0.0.1:8080/security/contentSecurityPolicy/resources/alert-fail.js' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
This page should neither alert "FAIL" nor generate any mixed content warnings in the console. This page should neither alert "FAIL" nor generate any mixed content warnings in the console.
CONSOLE WARNING: line 1: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-css.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/style.css': this content should also be loaded over HTTPS.
CONSOLE WARNING: line 4: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-css.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/style.css': this content should also be loaded over HTTPS. CONSOLE WARNING: line 4: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-css.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/style.css': this content should also be loaded over HTTPS.
This test loads a secure iframe that loads an insecure style sheet. We should trigger a mixed content callback because an active network attacker can use CSS3 to breach the confidentiality of the HTTPS security origin. This test loads a secure iframe that loads an insecure style sheet. We should trigger a mixed content callback because an active network attacker can use CSS3 to breach the confidentiality of the HTTPS security origin.
......
CONSOLE WARNING: line 1: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-css.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/style.css': this content should also be loaded over HTTPS.
CONSOLE WARNING: line 4: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-css.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/style.css': this content should also be loaded over HTTPS. CONSOLE WARNING: line 4: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-css.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/style.css': this content should also be loaded over HTTPS.
This test opens a window that loads an insecure style sheet. We should trigger a mixed content callback because the main frame in the window is HTTPS but is running insecure content. This test opens a window that loads an insecure style sheet. We should trigger a mixed content callback because the main frame in the window is HTTPS but is running insecure content.
CONSOLE WARNING: line 1: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-image.html' was loaded over HTTPS, but displayed insecure content from 'http://127.0.0.1:8080/security/resources/compass.jpg': this content should also be loaded over HTTPS. CONSOLE WARNING: line 1: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-image.html' was loaded over HTTPS, but displayed insecure content from 'http://127.0.0.1:8080/security/resources/compass.jpg': this content should also be loaded over HTTPS.
CONSOLE WARNING: line 1: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-image.html' was loaded over HTTPS, but displayed insecure content from 'http://127.0.0.1:8080/security/resources/compass.jpg': this content should also be loaded over HTTPS.
This test opens a window that loads an insecure image. We should trigger a mixed content callback even though we've set the preference to block this, because we've overriden the preference via a web permission client callback. This test opens a window that loads an insecure image. We should trigger a mixed content callback even though we've set the preference to block this, because we've overriden the preference via a web permission client callback.
CONSOLE ERROR: line 1: [blocked] The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-image.html' was loaded over HTTPS, but displayed insecure content from 'http://127.0.0.1:8080/security/resources/compass.jpg': this content should also be loaded over HTTPS. CONSOLE ERROR: line 1: [blocked] The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-image.html' was loaded over HTTPS, but displayed insecure content from 'http://127.0.0.1:8080/security/resources/compass.jpg': this content should also be loaded over HTTPS.
CONSOLE ERROR: line 1: [blocked] The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-image.html' was loaded over HTTPS, but displayed insecure content from 'http://127.0.0.1:8080/security/resources/compass.jpg': this content should also be loaded over HTTPS.
This test opens a window that loads an insecure image. We should not trigger a mixed content callback even though the main frame in the window is HTTPS and is displaying insecure content, because we've set the preference to block this. This test opens a window that loads an insecure image. We should not trigger a mixed content callback even though the main frame in the window is HTTPS and is displaying insecure content, because we've set the preference to block this.
CONSOLE WARNING: line 1: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-image.html' was loaded over HTTPS, but displayed insecure content from 'http://127.0.0.1:8080/security/resources/compass.jpg': this content should also be loaded over HTTPS. CONSOLE WARNING: line 1: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-image.html' was loaded over HTTPS, but displayed insecure content from 'http://127.0.0.1:8080/security/resources/compass.jpg': this content should also be loaded over HTTPS.
CONSOLE WARNING: line 1: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-image.html' was loaded over HTTPS, but displayed insecure content from 'http://127.0.0.1:8080/security/resources/compass.jpg': this content should also be loaded over HTTPS.
This test opens a window that loads an insecure image. We should trigger a mixed content callback because the main frame in the window is HTTPS but is displaying insecure content. This test opens a window that loads an insecure image. We should trigger a mixed content callback because the main frame in the window is HTTPS but is displaying insecure content.
CONSOLE ERROR: [blocked] The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-data-url-frame-with-script.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/script.js': this content should also be loaded over HTTPS. CONSOLE ERROR: [blocked] The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-data-url-frame-with-script.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/script.js': this content should also be loaded over HTTPS.
CONSOLE ERROR: [blocked] The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-data-url-frame-with-script.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/script.js': this content should also be loaded over HTTPS.
This test opens a window that loads a data: iframe that loads an insecure script, and that the script is still blocked. Although the data: frame has a separate origin, the script can still navigate top. This test opens a window that loads a data: iframe that loads an insecure script, and that the script is still blocked. Although the data: frame has a separate origin, the script can still navigate top.
CONSOLE WARNING: line 1: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-script.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/script.js': this content should also be loaded over HTTPS.
CONSOLE WARNING: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-script.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/script.js': this content should also be loaded over HTTPS. CONSOLE WARNING: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-script.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/script.js': this content should also be loaded over HTTPS.
This test loads a secure iframe that loads an insecure script. We should trigger a mixed content callback even though the main frame is HTTP because the HTTPS frame's origin is contaminated with an insecure script. This test loads a secure iframe that loads an insecure script. We should trigger a mixed content callback even though the main frame is HTTP because the HTTPS frame's origin is contaminated with an insecure script.
......
CONSOLE WARNING: line 1: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-script.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/script.js': this content should also be loaded over HTTPS.
CONSOLE WARNING: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-script.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/script.js': this content should also be loaded over HTTPS. CONSOLE WARNING: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-script.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/script.js': this content should also be loaded over HTTPS.
This test opens a window that loads an insecure script. We should trigger a mixed content callback even though we've set the preference to block this, because we've overriden the preference via a web permission client callback. This test opens a window that loads an insecure script. We should trigger a mixed content callback even though we've set the preference to block this, because we've overriden the preference via a web permission client callback.
CONSOLE ERROR: line 1: [blocked] The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-script.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/script.js': this content should also be loaded over HTTPS.
CONSOLE ERROR: [blocked] The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-script.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/script.js': this content should also be loaded over HTTPS. CONSOLE ERROR: [blocked] The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-insecure-script.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/mixedContent/resources/script.js': this content should also be loaded over HTTPS.
This test opens a window that loads an insecure script. We should not trigger a mixed content callback even though the main frame in the window is HTTPS and is running insecure scripts, because we've set the preference to block this. This test opens a window that loads an insecure script. We should not trigger a mixed content callback even though the main frame in the window is HTTPS and is running insecure scripts, because we've set the preference to block this.
CONSOLE WARNING: line 1: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-redirect-http-to-https-script.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/resources/redir.php?url=https://127.0.0.1:8443/security/mixedContent/resources/script.js': this content should also be loaded over HTTPS.
CONSOLE WARNING: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-redirect-http-to-https-script.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/resources/redir.php?url=https://127.0.0.1:8443/security/mixedContent/resources/script.js': this content should also be loaded over HTTPS. CONSOLE WARNING: The page at 'https://127.0.0.1:8443/security/mixedContent/resources/frame-with-redirect-http-to-https-script.html' was loaded over HTTPS, but ran insecure content from 'http://127.0.0.1:8080/security/resources/redir.php?url=https://127.0.0.1:8443/security/mixedContent/resources/script.js': this content should also be loaded over HTTPS.
This test loads a secure iframe that loads an insecure script (but with a tricky redirect). We should trigger a mixed content callback because an active network attacker could have redirected the script load to https://attacker.com. This test loads a secure iframe that loads an insecure script (but with a tricky redirect). We should trigger a mixed content callback because an active network attacker could have redirected the script load to https://attacker.com.
......
shouldnotexecute.js has MIME type application/x-javascript
Unknown script types should not be loaded nor executed. If this test fails, an more than one line will appear in the output with the script's MIME type. One line is OK, as it's from the prelaoder (which has no concept of invalid script types and will happily issue a preload).
Blocked access to external URL http://bugzilla.mozilla.org/notfound
layer at (0,0) size 800x600 layer at (0,0) size 800x600
RenderView at (0,0) size 800x600 RenderView at (0,0) size 800x600
layer at (0,0) size 800x600 layer at (0,0) size 800x600
......
...@@ -900,10 +900,6 @@ ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy ...@@ -900,10 +900,6 @@ ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy
// If the same URL has been loaded as a different type, we need to reload. // If the same URL has been loaded as a different type, we need to reload.
if (existingResource->type() != type) { if (existingResource->type() != type) {
// FIXME: If existingResource is a Preload and the new type is LinkPrefetch
// We really should discard the new prefetch since the preload has more
// specific type information! crbug.com/379893
// fast/dom/HTMLLinkElement/link-and-subresource-test hits this case.
WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy reloading due to type mismatch."); WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy reloading due to type mismatch.");
return Reload; return Reload;
} }
...@@ -939,10 +935,6 @@ ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy ...@@ -939,10 +935,6 @@ ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy
if (m_allowStaleResources) if (m_allowStaleResources)
return Use; return Use;
// If fetching a resource with a different 'CORS enabled' flag, reload.
if (type != Resource::MainResource && options.corsEnabled != existingResource->options().corsEnabled)
return Reload;
// Always use preloads. // Always use preloads.
if (existingResource->isPreloaded()) if (existingResource->isPreloaded())
return Use; return Use;
...@@ -958,6 +950,10 @@ ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy ...@@ -958,6 +950,10 @@ ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy
return Reload; return Reload;
} }
// If fetching a resource with a different 'CORS enabled' flag, reload.
if (type != Resource::MainResource && options.corsEnabled != existingResource->options().corsEnabled)
return Reload;
// If credentials were sent with the previous request and won't be // If credentials were sent with the previous request and won't be
// with this one, or vice versa, re-fetch the resource. // with this one, or vice versa, re-fetch the resource.
// //
......
...@@ -355,13 +355,7 @@ void HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<Pa ...@@ -355,13 +355,7 @@ void HTMLDocumentParser::didReceiveParsedChunkFromBackgroundParser(PassOwnPtr<Pa
RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this); RefPtrWillBeRawPtr<HTMLDocumentParser> protect(this);
ASSERT(m_speculations.isEmpty()); ASSERT(m_speculations.isEmpty());
// This preload call is redundant, but we plan to change treebuilding to chunk->preloads.clear(); // We don't need to preload because we're going to parse immediately.
// always operate asynchronously after a message-loop round trip after delivery
// to the main thread, thus we'll always use the preloader. Before making
// that change, we're sending all chunks through the preloader right
// before treebuilding (changes 15 layout tests).
// https://codereview.chromium.org/258013009/
m_preloader->takeAndPreload(chunk->preloads);
m_speculations.append(chunk); m_speculations.append(chunk);
pumpPendingSpeculations(); pumpPendingSpeculations();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment