Diff
Modified: trunk/LayoutTests/ChangeLog (199649 => 199650)
--- trunk/LayoutTests/ChangeLog 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/LayoutTests/ChangeLog 2016-04-18 06:06:42 UTC (rev 199650)
@@ -1,3 +1,25 @@
+2016-04-17 Yoav Weiss <[email protected]>
+
+ Initial Link preload support
+ https://bugs.webkit.org/show_bug.cgi?id=156334
+
+ Added tests that make sure that `<link rel=preload>` performs its basic
+ tasks and preloads resources.
+
+ Reviewed by Darin Adler.
+
+ * http/tests/preload/download_resources-expected.txt: Added.
+ * http/tests/preload/download_resources.html: Added.
+ * http/tests/preload/dynamic_adding_preload-expected.txt: Added.
+ * http/tests/preload/dynamic_adding_preload.html: Added.
+ * http/tests/preload/dynamic_remove_preload_href-expected.txt: Added.
+ * http/tests/preload/dynamic_remove_preload_href.html: Added.
+ * http/tests/preload/dynamic_removing_preload-expected.txt: Added.
+ * http/tests/preload/dynamic_removing_preload.html: Added.
+ * imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt: Adjusted expected results to progressions.
+ * imported/w3c/web-platform-tests/html/dom/reflection-metadata-expected.txt: Adjusted expected results to progressions.
+ * platform/ios-simulator/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt: Adjusted expected results to progressions.
+
2016-04-17 Youenn Fablet <[email protected]>
[Streams] Consume HTTP data as a ReadableStream
Added: trunk/LayoutTests/http/tests/preload/download_resources-expected.txt (0 => 199650)
--- trunk/LayoutTests/http/tests/preload/download_resources-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/preload/download_resources-expected.txt 2016-04-18 06:06:42 UTC (rev 199650)
@@ -0,0 +1,13 @@
+CONSOLE MESSAGE: line 15: <link rel=preload> must have a valid `as` value
+PASS internals.isPreloaded('../resources/dummy.js'); is true
+PASS internals.isPreloaded('../resources/dummy.css'); is true
+PASS internals.isPreloaded('../resources/square.png'); is true
+PASS internals.isPreloaded('../resources/Ahem.ttf'); is true
+PASS internals.isPreloaded('../resources/test.mp4'); is true
+PASS internals.isPreloaded('../security/resources/captions.vtt'); is true
+PASS internals.isPreloaded('../resources/dummy.xml?badvalue'); is false
+PASS internals.isPreloaded('../resources/dummy.xml'); is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/preload/download_resources.html (0 => 199650)
--- trunk/LayoutTests/http/tests/preload/download_resources.html (rev 0)
+++ trunk/LayoutTests/http/tests/preload/download_resources.html 2016-04-18 06:06:42 UTC (rev 199650)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+ if (window.internals)
+ window.internals.setLinkPreloadSupport(true);
+</script>
+<script src=""
+<link rel=preload href="" as=script>
+<link rel=preload href="" as=style>
+<link rel=preload href="" as=image>
+<link rel=preload href="" as=font crossorigin>
+<link rel=preload href="" as=media>
+<link rel=preload href="" as=track>
+<link rel=preload href="" as=foobarxmlthing>
+<link rel=preload href=""
+<script src=""
+</head>
+<body>
+<script>
+ if (window.testRunner)
+ testRunner.dumpAsText();
+ shouldBeTrue("internals.isPreloaded('../resources/dummy.js');");
+ shouldBeTrue("internals.isPreloaded('../resources/dummy.css');");
+ shouldBeTrue("internals.isPreloaded('../resources/square.png');");
+ shouldBeTrue("internals.isPreloaded('../resources/Ahem.ttf');");
+ shouldBeTrue("internals.isPreloaded('../resources/test.mp4');");
+ shouldBeTrue("internals.isPreloaded('../security/resources/captions.vtt');");
+ shouldBeFalse("internals.isPreloaded('../resources/dummy.xml?badvalue');");
+ shouldBeTrue("internals.isPreloaded('../resources/dummy.xml');");
+</script>
+<script>
+ if (window.internals)
+ window.internals.setLinkPreloadSupport(false);
+</script>
Added: trunk/LayoutTests/http/tests/preload/dynamic_adding_preload-expected.txt (0 => 199650)
--- trunk/LayoutTests/http/tests/preload/dynamic_adding_preload-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/preload/dynamic_adding_preload-expected.txt 2016-04-18 06:06:42 UTC (rev 199650)
@@ -0,0 +1,5 @@
+PASS internals.isPreloaded('../resources/dummy.js'); is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/preload/dynamic_adding_preload.html (0 => 199650)
--- trunk/LayoutTests/http/tests/preload/dynamic_adding_preload.html (rev 0)
+++ trunk/LayoutTests/http/tests/preload/dynamic_adding_preload.html 2016-04-18 06:06:42 UTC (rev 199650)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+ if (window.internals)
+ window.internals.setLinkPreloadSupport(true);
+</script>
+<script src=""
+<body>
+<script>
+ var link = document.createElement("link");
+ link.as = "script";
+ link.rel = "preload";
+ link.href = ""
+ document.body.appendChild(link);
+</script>
+<script src=""
+<script>
+ shouldBeTrue("internals.isPreloaded('../resources/dummy.js');");
+
+ if (window.internals)
+ window.internals.setLinkPreloadSupport(false);
+</script>
+</body>
Added: trunk/LayoutTests/http/tests/preload/dynamic_remove_preload_href-expected.txt (0 => 199650)
--- trunk/LayoutTests/http/tests/preload/dynamic_remove_preload_href-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/preload/dynamic_remove_preload_href-expected.txt 2016-04-18 06:06:42 UTC (rev 199650)
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: line 16: <link rel=preload> has an invalid `href` value
+PASS internals.isPreloaded('../resources/dummy.js'); is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/preload/dynamic_remove_preload_href.html (0 => 199650)
--- trunk/LayoutTests/http/tests/preload/dynamic_remove_preload_href.html (rev 0)
+++ trunk/LayoutTests/http/tests/preload/dynamic_remove_preload_href.html 2016-04-18 06:06:42 UTC (rev 199650)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+ if (window.internals)
+ window.internals.setLinkPreloadSupport(true);
+</script>
+<script src=""
+<body>
+<script>
+ var link = document.createElement("link");
+ link.as = "script";
+ link.rel = "preload";
+ link.href = ""
+ document.body.appendChild(link);
+ link.href = ""
+ window.addEventListener("load", function() {
+ shouldBeFalse("internals.isPreloaded('../resources/dummy.js');");
+ });
+</script>
+<script src=""
+<script>
+ if (window.internals)
+ window.internals.setLinkPreloadSupport(false);
+</script>
+</body>
Added: trunk/LayoutTests/http/tests/preload/dynamic_removing_preload-expected.txt (0 => 199650)
--- trunk/LayoutTests/http/tests/preload/dynamic_removing_preload-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/preload/dynamic_removing_preload-expected.txt 2016-04-18 06:06:42 UTC (rev 199650)
@@ -0,0 +1,5 @@
+PASS internals.isPreloaded('../resources/dummy.js'); is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/preload/dynamic_removing_preload.html (0 => 199650)
--- trunk/LayoutTests/http/tests/preload/dynamic_removing_preload.html (rev 0)
+++ trunk/LayoutTests/http/tests/preload/dynamic_removing_preload.html 2016-04-18 06:06:42 UTC (rev 199650)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<body>
+<script>
+ var link = document.createElement("link");
+ link.as = "script";
+ link.rel = "preload";
+ link.href = ""
+ document.body.appendChild(link);
+ document.body.removeChild(link);
+ window.addEventListener("load", function() {
+ shouldBeFalse("internals.isPreloaded('../resources/dummy.js');");
+ });
+</script>
+<script src=""
+</body>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt (199649 => 199650)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt 2016-04-18 06:06:42 UTC (rev 199650)
@@ -1366,7 +1366,7 @@
PASS HTMLLinkElement interface: existence and properties of interface prototype object
PASS HTMLLinkElement interface: existence and properties of interface prototype object's "constructor" property
PASS HTMLLinkElement interface: attribute href
-FAIL HTMLLinkElement interface: attribute crossOrigin assert_true: The prototype object must have a property "crossOrigin" expected true got false
+PASS HTMLLinkElement interface: attribute crossOrigin
PASS HTMLLinkElement interface: attribute rel
PASS HTMLLinkElement interface: attribute relList
PASS HTMLLinkElement interface: attribute media
@@ -1379,7 +1379,7 @@
PASS HTMLLinkElement must be primary interface of document.createElement("link")
PASS Stringification of document.createElement("link")
PASS HTMLLinkElement interface: document.createElement("link") must inherit property "href" with the proper type (0)
-FAIL HTMLLinkElement interface: document.createElement("link") must inherit property "crossOrigin" with the proper type (1) assert_inherits: property "crossOrigin" not found in prototype chain
+PASS HTMLLinkElement interface: document.createElement("link") must inherit property "crossOrigin" with the proper type (1)
PASS HTMLLinkElement interface: document.createElement("link") must inherit property "rel" with the proper type (2)
PASS HTMLLinkElement interface: document.createElement("link") must inherit property "relList" with the proper type (3)
PASS HTMLLinkElement interface: document.createElement("link") must inherit property "media" with the proper type (4)
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-metadata-expected.txt (199649 => 199650)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-metadata-expected.txt 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-metadata-expected.txt 2016-04-18 06:06:42 UTC (rev 199650)
@@ -3051,132 +3051,132 @@
PASS link.href: IDL set to object "test-valueOf" should not throw
PASS link.href: IDL set to object "test-valueOf" followed by getAttribute()
PASS link.href: IDL set to object "test-valueOf" followed by IDL get
-FAIL link.crossOrigin: typeof IDL attribute assert_equals: expected "string" but got "undefined"
-FAIL link.crossOrigin: IDL get with DOM attribute unset assert_equals: expected (string) "" but got (undefined) undefined
+FAIL link.crossOrigin: typeof IDL attribute assert_equals: expected "string" but got "object"
+FAIL link.crossOrigin: IDL get with DOM attribute unset assert_equals: expected (string) "" but got (object) null
PASS link.crossOrigin: setAttribute() to "" followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to "" followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to "" followed by IDL get
PASS link.crossOrigin: setAttribute() to " \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f foo " followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to " \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f foo " followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to " \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f foo " followed by IDL get
PASS link.crossOrigin: setAttribute() to undefined followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to undefined followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to undefined followed by IDL get
PASS link.crossOrigin: setAttribute() to 7 followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to 7 followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to 7 followed by IDL get
PASS link.crossOrigin: setAttribute() to 1.5 followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to 1.5 followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to 1.5 followed by IDL get
PASS link.crossOrigin: setAttribute() to true followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to true followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to true followed by IDL get
PASS link.crossOrigin: setAttribute() to false followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to false followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to false followed by IDL get
PASS link.crossOrigin: setAttribute() to object "[object Object]" followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to object "[object Object]" followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to object "[object Object]" followed by IDL get
PASS link.crossOrigin: setAttribute() to NaN followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to NaN followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to NaN followed by IDL get
PASS link.crossOrigin: setAttribute() to Infinity followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to Infinity followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to Infinity followed by IDL get
PASS link.crossOrigin: setAttribute() to -Infinity followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to -Infinity followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to -Infinity followed by IDL get
PASS link.crossOrigin: setAttribute() to "\0" followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to "\0" followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to "\0" followed by IDL get
PASS link.crossOrigin: setAttribute() to null followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to null followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to null followed by IDL get
PASS link.crossOrigin: setAttribute() to object "test-toString" followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to object "test-toString" followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to object "test-toString" followed by IDL get
PASS link.crossOrigin: setAttribute() to object "test-valueOf" followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to object "test-valueOf" followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to object "test-valueOf" followed by IDL get
PASS link.crossOrigin: setAttribute() to "anonymous" followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to "anonymous" followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to "anonymous" followed by IDL get
PASS link.crossOrigin: setAttribute() to "xanonymous" followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to "xanonymous" followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to "xanonymous" followed by IDL get
PASS link.crossOrigin: setAttribute() to "anonymous\0" followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to "anonymous\0" followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to "anonymous\0" followed by IDL get
PASS link.crossOrigin: setAttribute() to "nonymous" followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to "nonymous" followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to "nonymous" followed by IDL get
PASS link.crossOrigin: setAttribute() to "ANONYMOUS" followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to "ANONYMOUS" followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to "ANONYMOUS" followed by IDL get
PASS link.crossOrigin: setAttribute() to "use-credentials" followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to "use-credentials" followed by IDL get assert_equals: expected (string) "use-credentials" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to "use-credentials" followed by IDL get
PASS link.crossOrigin: setAttribute() to "xuse-credentials" followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to "xuse-credentials" followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to "xuse-credentials" followed by IDL get
PASS link.crossOrigin: setAttribute() to "use-credentials\0" followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to "use-credentials\0" followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to "use-credentials\0" followed by IDL get
PASS link.crossOrigin: setAttribute() to "se-credentials" followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to "se-credentials" followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to "se-credentials" followed by IDL get
PASS link.crossOrigin: setAttribute() to "USE-CREDENTIALS" followed by getAttribute()
-FAIL link.crossOrigin: setAttribute() to "USE-CREDENTIALS" followed by IDL get assert_equals: expected (string) "use-credentials" but got (undefined) undefined
+PASS link.crossOrigin: setAttribute() to "USE-CREDENTIALS" followed by IDL get
PASS link.crossOrigin: IDL set to "" should not throw
-FAIL link.crossOrigin: IDL set to "" followed by getAttribute() assert_equals: expected "" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to "" followed by IDL get assert_equals: expected "anonymous" but got ""
+PASS link.crossOrigin: IDL set to "" followed by getAttribute()
+PASS link.crossOrigin: IDL set to "" followed by IDL get
PASS link.crossOrigin: IDL set to " \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f foo " should not throw
-FAIL link.crossOrigin: IDL set to " \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f foo " followed by getAttribute() assert_equals: expected " \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f foo " but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to " \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f foo " followed by IDL get assert_equals: expected "anonymous" but got " \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f foo "
+PASS link.crossOrigin: IDL set to " \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f foo " followed by getAttribute()
+PASS link.crossOrigin: IDL set to " \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f foo " followed by IDL get
PASS link.crossOrigin: IDL set to undefined should not throw
-FAIL link.crossOrigin: IDL set to undefined followed by getAttribute() assert_equals: expected "undefined" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to undefined followed by IDL get assert_equals: expected (string) "anonymous" but got (undefined) undefined
+FAIL link.crossOrigin: IDL set to undefined followed by getAttribute() assert_equals: expected (string) "undefined" but got (object) null
+FAIL link.crossOrigin: IDL set to undefined followed by IDL get assert_equals: expected (string) "anonymous" but got (object) null
PASS link.crossOrigin: IDL set to 7 should not throw
-FAIL link.crossOrigin: IDL set to 7 followed by getAttribute() assert_equals: expected "7" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to 7 followed by IDL get assert_equals: expected (string) "anonymous" but got (number) 7
+PASS link.crossOrigin: IDL set to 7 followed by getAttribute()
+PASS link.crossOrigin: IDL set to 7 followed by IDL get
PASS link.crossOrigin: IDL set to 1.5 should not throw
-FAIL link.crossOrigin: IDL set to 1.5 followed by getAttribute() assert_equals: expected "1.5" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to 1.5 followed by IDL get assert_equals: expected (string) "anonymous" but got (number) 1.5
+PASS link.crossOrigin: IDL set to 1.5 followed by getAttribute()
+PASS link.crossOrigin: IDL set to 1.5 followed by IDL get
PASS link.crossOrigin: IDL set to true should not throw
-FAIL link.crossOrigin: IDL set to true followed by getAttribute() assert_equals: expected "true" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to true followed by IDL get assert_equals: expected (string) "anonymous" but got (boolean) true
+PASS link.crossOrigin: IDL set to true followed by getAttribute()
+PASS link.crossOrigin: IDL set to true followed by IDL get
PASS link.crossOrigin: IDL set to false should not throw
-FAIL link.crossOrigin: IDL set to false followed by getAttribute() assert_equals: expected "false" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to false followed by IDL get assert_equals: expected (string) "anonymous" but got (boolean) false
+PASS link.crossOrigin: IDL set to false followed by getAttribute()
+PASS link.crossOrigin: IDL set to false followed by IDL get
PASS link.crossOrigin: IDL set to object "[object Object]" should not throw
-FAIL link.crossOrigin: IDL set to object "[object Object]" followed by getAttribute() assert_equals: expected "[object Object]" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to object "[object Object]" followed by IDL get assert_equals: expected (string) "anonymous" but got (object) object "[object Object]"
+PASS link.crossOrigin: IDL set to object "[object Object]" followed by getAttribute()
+PASS link.crossOrigin: IDL set to object "[object Object]" followed by IDL get
PASS link.crossOrigin: IDL set to NaN should not throw
-FAIL link.crossOrigin: IDL set to NaN followed by getAttribute() assert_equals: expected "NaN" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to NaN followed by IDL get assert_equals: expected (string) "anonymous" but got (number) NaN
+PASS link.crossOrigin: IDL set to NaN followed by getAttribute()
+PASS link.crossOrigin: IDL set to NaN followed by IDL get
PASS link.crossOrigin: IDL set to Infinity should not throw
-FAIL link.crossOrigin: IDL set to Infinity followed by getAttribute() assert_equals: expected "Infinity" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to Infinity followed by IDL get assert_equals: expected (string) "anonymous" but got (number) Infinity
+PASS link.crossOrigin: IDL set to Infinity followed by getAttribute()
+PASS link.crossOrigin: IDL set to Infinity followed by IDL get
PASS link.crossOrigin: IDL set to -Infinity should not throw
-FAIL link.crossOrigin: IDL set to -Infinity followed by getAttribute() assert_equals: expected "-Infinity" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to -Infinity followed by IDL get assert_equals: expected (string) "anonymous" but got (number) -Infinity
+PASS link.crossOrigin: IDL set to -Infinity followed by getAttribute()
+PASS link.crossOrigin: IDL set to -Infinity followed by IDL get
PASS link.crossOrigin: IDL set to "\0" should not throw
-FAIL link.crossOrigin: IDL set to "\0" followed by getAttribute() assert_equals: expected "\0" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to "\0" followed by IDL get assert_equals: expected "anonymous" but got "\0"
+PASS link.crossOrigin: IDL set to "\0" followed by getAttribute()
+PASS link.crossOrigin: IDL set to "\0" followed by IDL get
PASS link.crossOrigin: IDL set to null should not throw
FAIL link.crossOrigin: IDL set to null followed by IDL get assert_equals: expected (string) "anonymous" but got (object) null
PASS link.crossOrigin: IDL set to object "test-toString" should not throw
-FAIL link.crossOrigin: IDL set to object "test-toString" followed by getAttribute() assert_equals: expected "test-toString" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to object "test-toString" followed by IDL get assert_equals: expected (string) "anonymous" but got (object) object "test-toString"
+PASS link.crossOrigin: IDL set to object "test-toString" followed by getAttribute()
+PASS link.crossOrigin: IDL set to object "test-toString" followed by IDL get
PASS link.crossOrigin: IDL set to object "test-valueOf" should not throw
-FAIL link.crossOrigin: IDL set to object "test-valueOf" followed by getAttribute() assert_equals: expected "test-valueOf" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to object "test-valueOf" followed by IDL get assert_equals: expected (string) "anonymous" but got (object) object "test-valueOf"
+PASS link.crossOrigin: IDL set to object "test-valueOf" followed by getAttribute()
+PASS link.crossOrigin: IDL set to object "test-valueOf" followed by IDL get
PASS link.crossOrigin: IDL set to "anonymous" should not throw
-FAIL link.crossOrigin: IDL set to "anonymous" followed by getAttribute() assert_equals: expected "anonymous" but got "USE-CREDENTIALS"
+PASS link.crossOrigin: IDL set to "anonymous" followed by getAttribute()
PASS link.crossOrigin: IDL set to "anonymous" followed by IDL get
PASS link.crossOrigin: IDL set to "xanonymous" should not throw
-FAIL link.crossOrigin: IDL set to "xanonymous" followed by getAttribute() assert_equals: expected "xanonymous" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to "xanonymous" followed by IDL get assert_equals: expected "anonymous" but got "xanonymous"
+PASS link.crossOrigin: IDL set to "xanonymous" followed by getAttribute()
+PASS link.crossOrigin: IDL set to "xanonymous" followed by IDL get
PASS link.crossOrigin: IDL set to "anonymous\0" should not throw
-FAIL link.crossOrigin: IDL set to "anonymous\0" followed by getAttribute() assert_equals: expected "anonymous\0" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to "anonymous\0" followed by IDL get assert_equals: expected "anonymous" but got "anonymous\0"
+PASS link.crossOrigin: IDL set to "anonymous\0" followed by getAttribute()
+PASS link.crossOrigin: IDL set to "anonymous\0" followed by IDL get
PASS link.crossOrigin: IDL set to "nonymous" should not throw
-FAIL link.crossOrigin: IDL set to "nonymous" followed by getAttribute() assert_equals: expected "nonymous" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to "nonymous" followed by IDL get assert_equals: expected "anonymous" but got "nonymous"
+PASS link.crossOrigin: IDL set to "nonymous" followed by getAttribute()
+PASS link.crossOrigin: IDL set to "nonymous" followed by IDL get
PASS link.crossOrigin: IDL set to "ANONYMOUS" should not throw
-FAIL link.crossOrigin: IDL set to "ANONYMOUS" followed by getAttribute() assert_equals: expected "ANONYMOUS" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to "ANONYMOUS" followed by IDL get assert_equals: expected "anonymous" but got "ANONYMOUS"
+PASS link.crossOrigin: IDL set to "ANONYMOUS" followed by getAttribute()
+PASS link.crossOrigin: IDL set to "ANONYMOUS" followed by IDL get
PASS link.crossOrigin: IDL set to "use-credentials" should not throw
-FAIL link.crossOrigin: IDL set to "use-credentials" followed by getAttribute() assert_equals: expected "use-credentials" but got "USE-CREDENTIALS"
+PASS link.crossOrigin: IDL set to "use-credentials" followed by getAttribute()
PASS link.crossOrigin: IDL set to "use-credentials" followed by IDL get
PASS link.crossOrigin: IDL set to "xuse-credentials" should not throw
-FAIL link.crossOrigin: IDL set to "xuse-credentials" followed by getAttribute() assert_equals: expected "xuse-credentials" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to "xuse-credentials" followed by IDL get assert_equals: expected "anonymous" but got "xuse-credentials"
+PASS link.crossOrigin: IDL set to "xuse-credentials" followed by getAttribute()
+PASS link.crossOrigin: IDL set to "xuse-credentials" followed by IDL get
PASS link.crossOrigin: IDL set to "use-credentials\0" should not throw
-FAIL link.crossOrigin: IDL set to "use-credentials\0" followed by getAttribute() assert_equals: expected "use-credentials\0" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to "use-credentials\0" followed by IDL get assert_equals: expected "anonymous" but got "use-credentials\0"
+PASS link.crossOrigin: IDL set to "use-credentials\0" followed by getAttribute()
+PASS link.crossOrigin: IDL set to "use-credentials\0" followed by IDL get
PASS link.crossOrigin: IDL set to "se-credentials" should not throw
-FAIL link.crossOrigin: IDL set to "se-credentials" followed by getAttribute() assert_equals: expected "se-credentials" but got "USE-CREDENTIALS"
-FAIL link.crossOrigin: IDL set to "se-credentials" followed by IDL get assert_equals: expected "anonymous" but got "se-credentials"
+PASS link.crossOrigin: IDL set to "se-credentials" followed by getAttribute()
+PASS link.crossOrigin: IDL set to "se-credentials" followed by IDL get
PASS link.crossOrigin: IDL set to "USE-CREDENTIALS" should not throw
PASS link.crossOrigin: IDL set to "USE-CREDENTIALS" followed by getAttribute()
-FAIL link.crossOrigin: IDL set to "USE-CREDENTIALS" followed by IDL get assert_equals: expected "use-credentials" but got "USE-CREDENTIALS"
+PASS link.crossOrigin: IDL set to "USE-CREDENTIALS" followed by IDL get
PASS link.rel: typeof IDL attribute
PASS link.rel: IDL get with DOM attribute unset
PASS link.rel: setAttribute() to "" followed by getAttribute()
Modified: trunk/LayoutTests/platform/ios-simulator/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt (199649 => 199650)
--- trunk/LayoutTests/platform/ios-simulator/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/LayoutTests/platform/ios-simulator/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt 2016-04-18 06:06:42 UTC (rev 199650)
@@ -1366,7 +1366,7 @@
PASS HTMLLinkElement interface: existence and properties of interface prototype object
PASS HTMLLinkElement interface: existence and properties of interface prototype object's "constructor" property
PASS HTMLLinkElement interface: attribute href
-FAIL HTMLLinkElement interface: attribute crossOrigin assert_true: The prototype object must have a property "crossOrigin" expected true got false
+PASS HTMLLinkElement interface: attribute crossOrigin
PASS HTMLLinkElement interface: attribute rel
PASS HTMLLinkElement interface: attribute relList
PASS HTMLLinkElement interface: attribute media
@@ -1379,7 +1379,7 @@
PASS HTMLLinkElement must be primary interface of document.createElement("link")
PASS Stringification of document.createElement("link")
PASS HTMLLinkElement interface: document.createElement("link") must inherit property "href" with the proper type (0)
-FAIL HTMLLinkElement interface: document.createElement("link") must inherit property "crossOrigin" with the proper type (1) assert_inherits: property "crossOrigin" not found in prototype chain
+PASS HTMLLinkElement interface: document.createElement("link") must inherit property "crossOrigin" with the proper type (1)
PASS HTMLLinkElement interface: document.createElement("link") must inherit property "rel" with the proper type (2)
PASS HTMLLinkElement interface: document.createElement("link") must inherit property "relList" with the proper type (3)
PASS HTMLLinkElement interface: document.createElement("link") must inherit property "media" with the proper type (4)
Modified: trunk/Source/WebCore/ChangeLog (199649 => 199650)
--- trunk/Source/WebCore/ChangeLog 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/ChangeLog 2016-04-18 06:06:42 UTC (rev 199650)
@@ -1,3 +1,56 @@
+2016-04-17 Yoav Weiss <[email protected]>
+
+ Initial Link preload support
+ https://bugs.webkit.org/show_bug.cgi?id=156334
+
+ Added basic `<link rel=preload>` functionality that enables preloading
+ of resources according to their type.
+
+ Reviewed by Darin Adler.
+
+ Tests: http/tests/preload/download_resources.html
+ http/tests/preload/dynamic_adding_preload.html
+ http/tests/preload/dynamic_remove_preload_href.html
+ http/tests/preload/dynamic_removing_preload.html
+
+ * bindings/generic/RuntimeEnabledFeatures.cpp: Added a runtime flag for the feature.
+ (WebCore::RuntimeEnabledFeatures::RuntimeEnabledFeatures):
+ * bindings/generic/RuntimeEnabledFeatures.h: Added a runtime flag for the feature.
+ (WebCore::RuntimeEnabledFeatures::setLinkPreloadEnabled):
+ (WebCore::RuntimeEnabledFeatures::linkPreloadEnabled):
+ * html/HTMLAttributeNames.in: Added an `as` attribute.
+ * html/HTMLLinkElement.cpp:
+ (WebCore::HTMLLinkElement::process): Added `as` and `crossorigin` attribute values to the loadLink() call.
+ (WebCore::HTMLLinkElement::setCrossOrigin): Setter for crossOrigin.
+ (WebCore::HTMLLinkElement::crossOrigin): Getter for crossOrigin.
+ * html/HTMLLinkElement.idl: Added `as` and `crossorigin` to HTMLLinkElement.
+ * html/HTMLLinkElement.h: Added getter and setter for crossorigin.
+ * html/LinkRelAttribute.cpp:
+ (WebCore::LinkRelAttribute::LinkRelAttribute): Added "preload" as a potential value.
+ * html/LinkRelAttribute.h: Added isLinkPreload.
+ * loader/LinkLoader.cpp:
+ (WebCore::LinkLoader::resourceTypeFromAsAttribute): Translates an `as` value into a resource type.
+ (WebCore::preloadIfNeeded): Triggers a resource preload when link element is a preload one.
+ (WebCore::LinkLoader::loadLink): Added a call to preloadIfNeeded.
+ * loader/LinkLoader.h: Added signatures.
+ * loader/ResourceLoadInfo.cpp:
+ (WebCore::toResourceType): Added LinkPreload as a possible CachedResource::type.
+ * loader/SubresourceLoader.cpp:
+ (WebCore::logResourceLoaded): Added LinkPreload as a possible CachedResource::type.
+ * loader/cache/CachedResource.cpp: Turned defaultPriorityForResourceType into a static member, as it's now also called from LinkLoader.
+ (WebCore::CachedResource::defaultPriorityForResourceType): Added LinkPreload as a possible CachedResource::type, giving it low priority.
+ (WebCore::defaultPriorityForResourceType): Deleted.
+ * loader/cache/CachedResource.h: Added LinkPreload as a possible CachedResource::type. Added defaultPriorityForResourceType as static.
+ * loader/cache/CachedResourceLoader.cpp:
+ (WebCore::contentTypeFromResourceType): Added LinkPreload as a possible CachedResource::type.
+ (WebCore::createResource): Added creation of a LinkPreload resource if needed.
+ (WebCore::CachedResourceLoader::checkInsecureContent): Added LinkPreload as a possible CachedResource::type.
+ (WebCore::CachedResourceLoader::canRequest): Added LinkPreload as a possible CachedResource::type.
+ * testing/Internals.cpp: Added function to turn on the link preload feature.
+ (WebCore::setLinkPreloadSupport):
+ * testing/Internals.idl: Added function to turn on the link preload feature.
+ * testing/Internals.h: Added function signature to turn on the link preload feature.
+
2016-04-17 Conrad Shultz <[email protected]>
Try (again) to fix debug builds after r199643.
Modified: trunk/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp (199649 => 199650)
--- trunk/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp 2016-04-18 06:06:42 UTC (rev 199650)
@@ -50,6 +50,7 @@
, m_isTouchEnabled(true)
, m_isDeviceMotionEnabled(true)
, m_isDeviceOrientationEnabled(true)
+ , m_isLinkPreloadEnabled(false)
, m_isCSSShapesEnabled(true)
, m_isCSSRegionsEnabled(false)
, m_isCSSCompositingEnabled(false)
Modified: trunk/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h (199649 => 199650)
--- trunk/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h 2016-04-18 06:06:42 UTC (rev 199650)
@@ -123,6 +123,9 @@
bool deviceOrientationEventEnabled() const { return m_isDeviceOrientationEnabled; }
bool ondeviceorientationEnabled() const { return m_isDeviceOrientationEnabled; }
+ void setLinkPreloadEnabled(bool isEnabled) { m_isLinkPreloadEnabled = isEnabled; }
+ bool linkPreloadEnabled() const { return m_isLinkPreloadEnabled; }
+
#if ENABLE(_javascript__I18N_API)
bool _javascript_I18NAPIEnabled() const;
void setJavaScriptI18NAPIEnabled(bool isEnabled) { m_isJavaScriptI18NAPIEnabled = isEnabled; }
@@ -248,6 +251,7 @@
bool m_isTouchEnabled;
bool m_isDeviceMotionEnabled;
bool m_isDeviceOrientationEnabled;
+ bool m_isLinkPreloadEnabled;
bool m_isCSSShapesEnabled;
bool m_isCSSRegionsEnabled;
bool m_isCSSCompositingEnabled;
Modified: trunk/Source/WebCore/html/HTMLAttributeNames.in (199649 => 199650)
--- trunk/Source/WebCore/html/HTMLAttributeNames.in 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/html/HTMLAttributeNames.in 2016-04-18 06:06:42 UTC (rev 199650)
@@ -59,6 +59,7 @@
aria-valuemin
aria-valuenow
aria-valuetext
+as
async
autocomplete
autofocus
Modified: trunk/Source/WebCore/html/HTMLLinkElement.cpp (199649 => 199650)
--- trunk/Source/WebCore/html/HTMLLinkElement.cpp 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/html/HTMLLinkElement.cpp 2016-04-18 06:06:42 UTC (rev 199650)
@@ -194,6 +194,16 @@
return true;
}
+void HTMLLinkElement::setCrossOrigin(const AtomicString& value)
+{
+ setAttributeWithoutSynchronization(crossoriginAttr, value);
+}
+
+String HTMLLinkElement::crossOrigin() const
+{
+ return parseCORSSettingsAttribute(fastGetAttribute(crossoriginAttr));
+}
+
void HTMLLinkElement::process()
{
if (!inDocument() || m_isInShadowTree) {
@@ -203,7 +213,7 @@
URL url = ""
- if (!m_linkLoader.loadLink(m_relAttribute, url, document()))
+ if (!m_linkLoader.loadLink(m_relAttribute, url, fastGetAttribute(asAttr), fastGetAttribute(crossoriginAttr), document()))
return;
bool treatAsStyleSheet = m_relAttribute.isStyleSheet
Modified: trunk/Source/WebCore/html/HTMLLinkElement.h (199649 => 199650)
--- trunk/Source/WebCore/html/HTMLLinkElement.h 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/html/HTMLLinkElement.h 2016-04-18 06:06:42 UTC (rev 199650)
@@ -67,6 +67,9 @@
bool isEnabledViaScript() const { return m_disabledState == EnabledViaScript; }
DOMTokenList& sizes();
+ void setCrossOrigin(const AtomicString&);
+ String crossOrigin() const;
+
void dispatchPendingEvent(LinkEventSender*);
static void dispatchPendingLoadEvents();
Modified: trunk/Source/WebCore/html/HTMLLinkElement.idl (199649 => 199650)
--- trunk/Source/WebCore/html/HTMLLinkElement.idl 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/html/HTMLLinkElement.idl 2016-04-18 06:06:42 UTC (rev 199650)
@@ -35,6 +35,8 @@
#endif
[Reflect] attribute DOMString target;
[Reflect] attribute DOMString type;
+ [Reflect] attribute DOMString as;
+ attribute DOMString? crossOrigin;
// DOM Level 2 Style
readonly attribute StyleSheet sheet;
Modified: trunk/Source/WebCore/html/LinkRelAttribute.cpp (199649 => 199650)
--- trunk/Source/WebCore/html/LinkRelAttribute.cpp 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/html/LinkRelAttribute.cpp 2016-04-18 06:06:42 UTC (rev 199650)
@@ -32,6 +32,7 @@
#include "config.h"
#include "LinkRelAttribute.h"
+#include "RuntimeEnabledFeatures.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -54,6 +55,8 @@
#endif
else if (equalLettersIgnoringASCIICase(rel, "dns-prefetch"))
isDNSPrefetch = true;
+ else if (RuntimeEnabledFeatures::sharedFeatures().linkPreloadEnabled() && equalLettersIgnoringASCIICase(rel, "preload"))
+ isLinkPreload = true;
else if (equalLettersIgnoringASCIICase(rel, "alternate stylesheet") || equalLettersIgnoringASCIICase(rel, "stylesheet alternate")) {
isStyleSheet = true;
isAlternate = true;
Modified: trunk/Source/WebCore/html/LinkRelAttribute.h (199649 => 199650)
--- trunk/Source/WebCore/html/LinkRelAttribute.h 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/html/LinkRelAttribute.h 2016-04-18 06:06:42 UTC (rev 199650)
@@ -42,6 +42,7 @@
IconType iconType { InvalidIcon };
bool isAlternate { false };
bool isDNSPrefetch { false };
+ bool isLinkPreload { false };
#if ENABLE(LINK_PREFETCH)
bool isLinkPrefetch { false };
bool isLinkSubresource { false };
Modified: trunk/Source/WebCore/loader/LinkLoader.cpp (199649 => 199650)
--- trunk/Source/WebCore/loader/LinkLoader.cpp 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/loader/LinkLoader.cpp 2016-04-18 06:06:42 UTC (rev 199650)
@@ -37,11 +37,13 @@
#include "CachedResourceLoader.h"
#include "CachedResourceRequest.h"
#include "ContainerNode.h"
+#include "CrossOriginAccessControl.h"
#include "Document.h"
#include "Frame.h"
#include "FrameLoaderClient.h"
#include "FrameView.h"
#include "LinkRelAttribute.h"
+#include "RuntimeEnabledFeatures.h"
#include "Settings.h"
#include "StyleResolver.h"
@@ -83,8 +85,57 @@
m_cachedLinkResource = nullptr;
}
-bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const URL& href, Document& document)
+Optional<CachedResource::Type> LinkLoader::resourceTypeFromAsAttribute(const String& as)
{
+ if (as.isEmpty())
+ return CachedResource::LinkPreload;
+ if (equalLettersIgnoringASCIICase(as, "image"))
+ return CachedResource::ImageResource;
+ if (equalLettersIgnoringASCIICase(as, "script"))
+ return CachedResource::Script;
+ if (equalLettersIgnoringASCIICase(as, "style"))
+ return CachedResource::CSSStyleSheet;
+ if (equalLettersIgnoringASCIICase(as, "media"))
+ return CachedResource::MediaResource;
+ if (equalLettersIgnoringASCIICase(as, "font"))
+ return CachedResource::FontResource;
+#if ENABLE(VIDEO_TRACK)
+ if (equalLettersIgnoringASCIICase(as, "track"))
+ return CachedResource::TextTrackResource;
+#endif
+ return Nullopt;
+}
+
+static void preloadIfNeeded(const LinkRelAttribute& relAttribute, const URL& href, Document& document, const String& as, const String& crossOriginMode)
+{
+ if (!document.loader() || !relAttribute.isLinkPreload)
+ return;
+
+ ASSERT(RuntimeEnabledFeatures::sharedFeatures().linkPreloadEnabled());
+ if (!href.isValid()) {
+ document.addConsoleMessage(MessageSource::Other, MessageLevel::Error, String("<link rel=preload> has an invalid `href` value"));
+ return;
+ }
+ auto type = LinkLoader::resourceTypeFromAsAttribute(as);
+ if (!type) {
+ document.addConsoleMessage(MessageSource::Other, MessageLevel::Error, String("<link rel=preload> must have a valid `as` value"));
+ return;
+ }
+
+ ResourceRequest resourceRequest(document.completeURL(href));
+ CachedResourceRequest linkRequest(resourceRequest, CachedResource::defaultPriorityForResourceType(type.value()));
+ linkRequest.setInitiator("link");
+
+ if (!crossOriginMode.isNull()) {
+ StoredCredentials allowCredentials = equalLettersIgnoringASCIICase(crossOriginMode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials;
+ updateRequestForAccessControl(linkRequest.mutableResourceRequest(), document.securityOrigin(), allowCredentials);
+ }
+ linkRequest.setForPreload(true);
+ document.cachedResourceLoader().preload(type.value(), linkRequest, emptyString());
+}
+
+bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const URL& href, const String& as, const String& crossOrigin, Document& document)
+{
// We'll record this URL per document, even if we later only use it in top level frames
if (relAttribute.iconType != InvalidIcon && href.isValid() && !href.isEmpty()) {
if (!m_client.shouldLoadLink())
@@ -101,6 +152,9 @@
document.frame()->loader().client().prefetchDNS(href.host());
}
+ if (m_client.shouldLoadLink())
+ preloadIfNeeded(relAttribute, href, document, as, crossOrigin);
+
#if ENABLE(LINK_PREFETCH)
if ((relAttribute.isLinkPrefetch || relAttribute.isLinkSubresource) && href.isValid() && document.frame()) {
if (!m_client.shouldLoadLink())
Modified: trunk/Source/WebCore/loader/LinkLoader.h (199649 => 199650)
--- trunk/Source/WebCore/loader/LinkLoader.h 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/loader/LinkLoader.h 2016-04-18 06:06:42 UTC (rev 199650)
@@ -32,6 +32,7 @@
#ifndef LinkLoader_h
#define LinkLoader_h
+#include "CachedResource.h"
#include "CachedResourceClient.h"
#include "CachedResourceHandle.h"
#include "LinkLoaderClient.h"
@@ -49,7 +50,8 @@
explicit LinkLoader(LinkLoaderClient&);
virtual ~LinkLoader();
- bool loadLink(const LinkRelAttribute&, const URL&, Document&);
+ bool loadLink(const LinkRelAttribute&, const URL&, const String& as, const String& crossOrigin, Document&);
+ static Optional<CachedResource::Type> resourceTypeFromAsAttribute(const String& as);
private:
void notifyFinished(CachedResource*) override;
Modified: trunk/Source/WebCore/loader/ResourceLoadInfo.cpp (199649 => 199650)
--- trunk/Source/WebCore/loader/ResourceLoadInfo.cpp 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/loader/ResourceLoadInfo.cpp 2016-04-18 06:06:42 UTC (rev 199650)
@@ -56,6 +56,7 @@
return ResourceType::Font;
case CachedResource::MediaResource:
+ case CachedResource::LinkPreload:
case CachedResource::RawResource:
return ResourceType::Raw;
Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (199649 => 199650)
--- trunk/Source/WebCore/loader/SubresourceLoader.cpp 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp 2016-04-18 06:06:42 UTC (rev 199650)
@@ -371,6 +371,7 @@
case CachedResource::SVGDocumentResource:
resourceType = DiagnosticLoggingKeys::svgDocumentKey();
break;
+ case CachedResource::LinkPreload:
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkPrefetch:
case CachedResource::LinkSubresource:
Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (199649 => 199650)
--- trunk/Source/WebCore/loader/cache/CachedResource.cpp 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp 2016-04-18 06:06:42 UTC (rev 199650)
@@ -63,7 +63,7 @@
namespace WebCore {
-static ResourceLoadPriority defaultPriorityForResourceType(CachedResource::Type type)
+ResourceLoadPriority CachedResource::defaultPriorityForResourceType(Type type)
{
switch (type) {
case CachedResource::MainResource:
@@ -86,6 +86,8 @@
#endif
case CachedResource::SVGDocumentResource:
return ResourceLoadPriority::Low;
+ case CachedResource::LinkPreload:
+ return ResourceLoadPriority::Low;
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkPrefetch:
return ResourceLoadPriority::VeryLow;
Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (199649 => 199650)
--- trunk/Source/WebCore/loader/cache/CachedResource.h 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h 2016-04-18 06:06:42 UTC (rev 199650)
@@ -75,6 +75,7 @@
#if ENABLE(XSLT)
, XSLStyleSheet
#endif
+ , LinkPreload
#if ENABLE(LINK_PREFETCH)
, LinkPrefetch
, LinkSubresource
@@ -263,6 +264,7 @@
#endif
unsigned long identifierForLoadWithoutResourceLoader() const { return m_identifierForLoadWithoutResourceLoader; }
+ static ResourceLoadPriority defaultPriorityForResourceType(Type);
protected:
void setEncodedSize(unsigned);
Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (199649 => 199650)
--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2016-04-18 06:06:42 UTC (rev 199650)
@@ -108,6 +108,8 @@
case CachedResource::XSLStyleSheet:
return new CachedXSLStyleSheet(request, sessionID);
#endif
+ case CachedResource::LinkPreload:
+ return new CachedResource(request, CachedResource::LinkPreload, sessionID);
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkPrefetch:
return new CachedResource(request, CachedResource::LinkPrefetch, sessionID);
@@ -313,6 +315,7 @@
return MixedContentChecker::ContentType::Active;
#endif
+ case CachedResource::LinkPreload:
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkPrefetch:
case CachedResource::LinkSubresource:
@@ -353,7 +356,8 @@
#if ENABLE(SVG_FONTS)
case CachedResource::SVGFontResource:
#endif
- case CachedResource::FontResource: {
+ case CachedResource::FontResource:
+ case CachedResource::LinkPreload: {
// These resources can corrupt only the frame's pixels.
if (Frame* f = frame()) {
Frame& topFrame = f->tree().top();
@@ -399,6 +403,7 @@
case CachedResource::MediaResource:
case CachedResource::FontResource:
case CachedResource::RawResource:
+ case CachedResource::LinkPreload:
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkPrefetch:
case CachedResource::LinkSubresource:
@@ -454,6 +459,8 @@
}
case CachedResource::MainResource:
case CachedResource::RawResource:
+ // FIXME: Preload should be subject to connect-src.
+ case CachedResource::LinkPreload:
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkPrefetch:
case CachedResource::LinkSubresource:
Modified: trunk/Source/WebCore/testing/Internals.cpp (199649 => 199650)
--- trunk/Source/WebCore/testing/Internals.cpp 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/testing/Internals.cpp 2016-04-18 06:06:42 UTC (rev 199650)
@@ -3328,4 +3328,9 @@
#endif
}
+void Internals::setLinkPreloadSupport(bool enable)
+{
+ RuntimeEnabledFeatures::sharedFeatures().setLinkPreloadEnabled(enable);
}
+
+}
Modified: trunk/Source/WebCore/testing/Internals.h (199649 => 199650)
--- trunk/Source/WebCore/testing/Internals.h 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/testing/Internals.h 2016-04-18 06:06:42 UTC (rev 199650)
@@ -471,6 +471,7 @@
String composedTreeAsText(Node&);
void setViewportForceAlwaysUserScalable(bool);
+ void setLinkPreloadSupport(bool);
private:
explicit Internals(Document&);
Modified: trunk/Source/WebCore/testing/Internals.idl (199649 => 199650)
--- trunk/Source/WebCore/testing/Internals.idl 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebCore/testing/Internals.idl 2016-04-18 06:06:42 UTC (rev 199650)
@@ -445,4 +445,5 @@
DOMString composedTreeAsText(Node parent);
void setViewportForceAlwaysUserScalable(boolean scalable);
+ void setLinkPreloadSupport(boolean scalable);
};
Modified: trunk/Source/WebKit2/ChangeLog (199649 => 199650)
--- trunk/Source/WebKit2/ChangeLog 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebKit2/ChangeLog 2016-04-18 06:06:42 UTC (rev 199650)
@@ -1,3 +1,13 @@
+2016-04-17 Yoav Weiss <[email protected]>
+
+ Initial Link preload support
+ https://bugs.webkit.org/show_bug.cgi?id=156334
+
+ Reviewed by Darin Adler.
+
+ * WebProcess/Network/WebLoaderStrategy.cpp:
+ (WebKit::maximumBufferingTime): Added LinkPreload as a possible CachedResource::type.
+
2016-04-17 Chris Dumez <[email protected]>
[WK2][iOS] Do not dlopen() QuickLook in the NetworkProcess
Modified: trunk/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp (199649 => 199650)
--- trunk/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp 2016-04-18 05:36:31 UTC (rev 199649)
+++ trunk/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp 2016-04-18 06:06:42 UTC (rev 199650)
@@ -110,6 +110,7 @@
case CachedResource::MainResource:
case CachedResource::RawResource:
case CachedResource::SVGDocumentResource:
+ case CachedResource::LinkPreload:
#if ENABLE(LINK_PREFETCH)
case CachedResource::LinkPrefetch:
case CachedResource::LinkSubresource: