Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/loading/doc-write-sync-third-party-script-block1.html

Issue 1849223002: Blocking synchronous and third party doc.written scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tests modified as per feedback and code comments added Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/loading/doc-write-sync-third-party-script-block1.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/loading/doc-write-sync-third-party-script-block1.html b/third_party/WebKit/LayoutTests/http/tests/loading/doc-write-sync-third-party-script-block1.html
new file mode 100644
index 0000000000000000000000000000000000000000..cc7329e0cebccbb0c0e0b11f41fe14236161bf3f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/loading/doc-write-sync-third-party-script-block1.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
jkarlin 2016/04/06 14:55:31 instead of ...-block1.html, how about ...-block-th
shivanisha 2016/04/06 20:40:09 sounds good. Will rename the three different test
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script>
+ var jsLoaded = false;
+ var loadsuccess = false;
Bryan McQuade 2016/04/06 12:37:21 for consistency let's name this loadSuccess
shivanisha 2016/04/06 14:18:36 done
+
+ src = 'http://localhost:8000/loading/resources/js-loaded.js';
+ document.write('<scr' + 'ipt src="' + src + '" onload="loadsuccess=true"></scr' + 'ipt>');
+</script>
+
+<script>
+ test(function () {
+ assert_true(jsLoaded);
+ assert_true(loadsuccess);
+ }, "Blocking script doesn't kick in since feature is disabled");
+
+</script>
+<script>
+ if (window.internals){
+ internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrame(true);
+ internals.setNetworkStateNotifierTestOnly(true);
+ internals.setNetworkConnectionInfo('cellular2g', 2.0);
+ }
+ src = './resources/js-loaded.js';
+ jsLoaded = false;
+ loadsuccess = false;
+ document.write('<scr' + 'ipt src="' + src + '" onload="loadsuccess=true"></scr' + 'ipt>');
+</script>
+
+<script>
+ test(function () {
+ assert_true(jsLoaded);
+ assert_true(loadsuccess);
+ }, "Same domain doc.written scripts are not blocked");
+</script>
+
+<script>
+ var jsLoaded = false;
+ var loadsuccess = false;
+
+ src = 'http://localhost:8000/loading/resources/js-loaded.js';
jkarlin 2016/04/06 14:55:31 It's subtle that this is a different origin. Can y
shivanisha 2016/04/06 20:40:09 sounds good
+ document.write('<scr' + 'ipt src="' + src + '" onload="loadsuccess=true"></scr' + 'ipt>');
+</script>
+
+<script>
+ test(function () {
+ assert_true(jsLoaded);
+ assert_true(loadsuccess);
+ }, "cross-origin script not blocked since it is cached");
+
+</script>
+<script>
+ jsLoaded = false;
+ loadsuccess = false;
+
+ src = 'http://localhost:8000/loading/resources/js-loaded1.js';
Bryan McQuade 2016/04/06 12:37:21 great, thanks! this is fine, but you might be able
shivanisha 2016/04/06 14:18:36 Yes, this works. Removing js-loaded1.js
+ document.write('<scr' + 'ipt src="' + src + '" onload="loadsuccess=true"></scr' + 'ipt>');
Bryan McQuade 2016/04/06 12:37:21 can we also add an onError="loadFailed=true" and a
shivanisha 2016/04/06 14:18:36 Added
+</script>
+
+<script>
+ test(function () {
+ assert_false(jsLoaded);
+ assert_false(loadsuccess);
+ }, "cross origin doc.written scripts are blocked");
+
+ window.addEventListener('beforeunload', function() {
+ internals.setNetworkStateNotifierTestOnly(false);
+ internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrame(false);
+ }, false);
+</script>

Powered by Google App Engine
This is Rietveld 408576698