diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/html/semantics/scripting-1/the-script-element | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/html/semantics/scripting-1/the-script-element')
55 files changed, 1410 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/.gitkeep b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/.gitkeep diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_001.htm b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_001.htm new file mode 100644 index 000000000..370152683 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_001.htm @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<html> + <head> + <title>Async property on a dynamically-created script is true by default</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> + <meta description="This test checks the Async property on a dynamically-created script element. By default it should be true." /> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-script-async"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <div id=log></div> + <script type="text/javascript"> + test(function() {assert_true(document.createElement("script").async)}, "Async property on a dynamically-created script is true by default"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_002.htm b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_002.htm new file mode 100644 index 000000000..e1850ff6e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_002.htm @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<html> + <head> + <title>Changes to the 'async' attribute are reflected in the async property</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> + <meta description="This test ensures changes to the 'async' attribute are reflected in the async property." /> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-script-async"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <div id=log></div> + <script type="text/javascript"> + test(function() { + var s = document.createElement("script"); + s.async = false; + s.setAttribute('async', ''); /*Should change s.async to true*/ + assert_true(s.async) + }, "Test 'async' attribute are reflected in the async property with setAttribute"); + + test(function() { + var s = document.createElement("script"); + s.async = false; + s.setAttribute('async', ''); /*Should change s.async to true*/ + s.removeAttribute('async'); /*Should change s.async to false*/ + assert_false(s.async) + }, "Test 'async' attribute are reflected in the async property with removeAttribute"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_003.htm b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_003.htm new file mode 100644 index 000000000..b9a854c6b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_003.htm @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<html> + <head> + <title>An async script does not block the parser while downloading</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> + <meta description="This test ensures an async script does not block the parser while downloading." /> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-script-async"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <div id=log></div> + <script type="text/javascript"> + var t = async_test("An async script does not block the parser while downloading"); + + function timeout() + { + t.step(function(){ assert_equals(document.getElementById("testresult").innerHTML, "21")}); + t.done(); + } + + var timer = setTimeout(timeout, 4000); + + function log(text) + { + var textNode = document.createTextNode(text); + document.getElementById("testresult").appendChild(textNode); + } + </script> + + <span id="testresult"></span> + + <script src="log.py?sec=3&id=1" async></script> + <script> + log('2'); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_004.htm b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_004.htm new file mode 100644 index 000000000..7908b757a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_004.htm @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<html> + <head> + <title>An async script executes as soon as possible after a download is complete</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> + <meta description="This test ensures an async script executes as soon as possible after a download is complete." /> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-script-async"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <div id=log></div> + <script type="text/javascript"> + var t = async_test("async script executes as soon as possible after a download is complete"); + + function timeout() + { + t.step(function(){ assert_equals(document.getElementById("testresult").innerHTML, "21")}); + t.done(); + } + + var timer = setTimeout(timeout, 4000); + + function log(text) + { + var textNode = document.createTextNode(text); + document.getElementById("testresult").appendChild(textNode); + } + </script> + + <span id="testresult"></span> + + <script src="log.py?sec=3&id=1" async></script> + <script src="log.py?sec=1&id=2" async></script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_005.htm b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_005.htm new file mode 100644 index 000000000..4519d7234 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_005.htm @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<html> + <head> + <title>A script element with both async and defer set should execute asynchronously</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> + <meta description="This test ensures a script element with both async and defer set should execute asynchronously." /> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-script-async"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <div id=log></div> + <script type="text/javascript"> + var t = async_test("A script element with both async and defer set should execute asynchronously"); + + function timeout() + { + t.step(function(){ assert_equals(document.getElementById("testresult").innerHTML, "2134")}); + t.done(); + } + + var timer = setTimeout(timeout, 5000); + + function log(text) + { + var textNode = document.createTextNode(text); + document.getElementById("testresult").appendChild(textNode); + } + </script> + + <span id="testresult"></span> + + <script type="text/javascript" src="log.py?sec=1&id=1" defer async></script> + <script type="text/javascript">log('2');</script> + <script type="text/javascript" src="log.py?sec=3&id=3"></script> + <script type="text/javascript">log('4');</script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_006.htm b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_006.htm new file mode 100644 index 000000000..86eb99897 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_006.htm @@ -0,0 +1,45 @@ +<!DOCTYPE html> +<html> + <head> + <title>A dynamically created external script executes asynchronously</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> + <meta description="This test ensures a dynamically created external script executes asynchronously." /> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#force-async"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <div id=log></div> + <script type="text/javascript"> + var t = async_test("dynamically created external script executes asynchronously"); + + function timeout() + { + t.step(function(){ assert_equals(document.getElementById("testresult").innerHTML, "321")}); + t.done(); + } + + var timer = setTimeout(timeout, 4000); + + function log(text) + { + var textNode = document.createTextNode(text); + document.getElementById("testresult").appendChild(textNode); + } + </script> + + <span id="testresult"></span> + <script type="text/javascript"> + var one = document.createElement("script"); + one.src="log.py?sec=3&id=1"; + document.head.appendChild(one); + + var two = document.createElement("script"); + two.src="log.py?sec=1&id=2"; + document.head.appendChild(two); + + log('3'); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_007.htm b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_007.htm new file mode 100644 index 000000000..8df0fba37 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_007.htm @@ -0,0 +1,48 @@ +<!DOCTYPE html> +<html> + <head> + <title>Ordered async script execution when script.async == false</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> + <meta description="This test ensures Ordered async script execution when script.async == false" /> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#script-processing-src-sync"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <div id=log></div> + <script type="text/javascript"> + var t = async_test("Ordered async script execution when script.async == false"); + + function timeout() + { + t.step(function(){ assert_equals(document.getElementById("testresult").innerHTML, "312")}); + t.done(); + } + + var timer = setTimeout(timeout, 8000); + + function log(text) + { + var textNode = document.createTextNode(text); + document.getElementById("testresult").appendChild(textNode); + } + </script> + + <span id="testresult"></span> + <script type="text/javascript"> + var one = document.createElement("script"); + one.src="log.py?sec=3&id=1"; + one.async = false; + document.head.appendChild(one); + + var two = document.createElement("script"); + two.src="log.py?sec=1&id=2"; + two.async = false; + document.head.appendChild(two); + </script> + <script type="text/javascript"> + log('3'); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_008.htm b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_008.htm new file mode 100644 index 000000000..73529cc31 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_008.htm @@ -0,0 +1,47 @@ +<!DOCTYPE html> +<html> + <head> + <title>Async script element execution delays the window's load event</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> + <meta description="This test ensures an async script element's execution delays the window's load event." /> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#delay-the-load-event"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <div id=log></div> + <script type="text/javascript"> + var t = async_test("Async script element execution delays the window's load event"); + + function timeout() + { + t.step(function(){ assert_equals(document.getElementById("testresult").innerHTML, "213")}); + t.done(); + } + + var timer = setTimeout(timeout, 8000); + + function log(text) + { + var textNode = document.createTextNode(text); + document.getElementById("testresult").appendChild(textNode); + } + </script> + + <span id="testresult"></span> + <script type="text/javascript"> + window.addEventListener("load", function() { + log("3"); + timeout(); + }, false); + + var s1 = document.createElement("script"); + s1.src = "log.py?sec=2&id=1"; + document.head.appendChild(s1); + </script> + <script type="text/javascript"> + log('2'); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_009.htm b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_009.htm new file mode 100644 index 000000000..501edda06 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_009.htm @@ -0,0 +1,25 @@ +<!DOCTYPE html> +<html> + <head> + <title>Document.write() silently fails from an Async script</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> + <meta description="This test ensures Document.write() silently fails from an Async script." /> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#execute-the-script-block"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script type="text/javascript"> + var t = async_test("Document.write() silently fails from an Async script"); + + var log = t.step_func(function() { + document.write("<span id='writtenText'/>"); + assert_equals(null, document.getElementById('writtenText')); + t.done(); + }); + </script> + </head> + <body> + <div id=log></div> + <script type="text/javascript" src="log.py?sec=1&id=1" async></script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_010.htm b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_010.htm new file mode 100644 index 000000000..959a8aa27 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_010.htm @@ -0,0 +1,54 @@ +<!DOCTYPE html> +<html> + <head> + <title>Removing an async script before execution</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> + <meta description="This test ensures that an async script still executes if it is removed from a markup before the download is complete. The other two scripts that come after it in insertion order should execute as well." /> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#execute-the-script-block"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script type="text/javascript"> + var t = async_test("Removing an async script before execution"); + + function timeout() + { + t.step(function(){ assert_equals(document.getElementById("testresult").innerHTML, "4123")}); + t.done(); + } + + var timer = setTimeout(timeout, 8000); + + function log(text) + { + var textNode = document.createTextNode(text); + document.getElementById("testresult").appendChild(textNode); + } + </script> + </head> + <body> + <div id=log></div> + <span id="testresult"></span> + <script type="text/javascript"> + var s1 = document.createElement("script"); + s1.src="log.py?sec=2&id=1"; + s1.async = false; + document.body.appendChild(s1); + + var s2 = document.createElement("script"); + s2.src="log.py?sec=1&id=2"; + s2.async = false; + document.body.appendChild(s2); + + var s3 = document.createElement("script"); + s3.id = "s3"; + s3.src="log.py?sec=0&id=3"; + s3.async = false; + document.body.appendChild(s3); + + //Remove s1 (Should still execute) + document.body.removeChild(s1); + </script> + <script type="text/javascript">log('4');</script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_011.htm b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_011.htm new file mode 100644 index 000000000..d80e463ce --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/async_011.htm @@ -0,0 +1,19 @@ +<!DOCTYPE html> +<html> + <head> + <title>An empty parser-inserted script element should return async=true</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> + <meta description="An empty parser-inserted script element should return async=true." /> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#prepare-a-script"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <div id=log></div> + <script></script> + <script type="text/javascript"> + test(function() { assert_true(document.getElementsByTagName("script")[2].async)}, "An empty parser-inserted script element should return async=true"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/contains.json b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/contains.json new file mode 100644 index 000000000..e31ce4003 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/contains.json @@ -0,0 +1,18 @@ +[ + { + "id": "scriptinglanguages", + "original_id": "scriptingLanguages" + }, + { + "id": "restrictions-for-contents-of-script-elements", + "original_id": "restrictions-for-contents-of-script-elements" + }, + { + "id": "inline-documentation-for-external-scripts", + "original_id": "inline-documentation-for-external-scripts" + }, + { + "id": "scripttagxslt", + "original_id": "scriptTagXSLT" + } +]
\ No newline at end of file diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/external-script-utf8.js b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/external-script-utf8.js new file mode 100644 index 000000000..eb442c97b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/external-script-utf8.js @@ -0,0 +1,5 @@ +(function() { + window.getSomeString = function() { + return "śćążź"; //<- these are five Polish letters, similar to scazz. It can be read correctly only with windows 1250 encoding. + }; +})(); diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/external-script-windows1250.js b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/external-script-windows1250.js new file mode 100644 index 000000000..50de6932b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/external-script-windows1250.js @@ -0,0 +1,5 @@ +(function() { + window.getSomeString = function() { + return "œæ¹¿Ÿ"; //<- these are five Polish letters, similar to scazz. It can be read correctly only with windows 1250 encoding. + }; +})(); diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/alpha/base.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/alpha/base.html new file mode 100644 index 000000000..dc0fa9dab --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/alpha/base.html @@ -0,0 +1,15 @@ +<!doctype html> +<meta charset=utf-8> +<title>Script src with a base URL</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<base href=../beta/> +<div id=log></div> +<script> +function do_test(path) { + test(function() { + assert_equals(path, "beta"); + }); +} +</script> +<script src=test.js></script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/alpha/test.js b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/alpha/test.js new file mode 100644 index 000000000..3cbbb12e2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/alpha/test.js @@ -0,0 +1 @@ +do_test("alpha"); diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/beta/test.js b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/beta/test.js new file mode 100644 index 000000000..4ce0f5338 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/beta/test.js @@ -0,0 +1 @@ +do_test("beta"); diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/empty-with-base.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/empty-with-base.html new file mode 100644 index 000000000..edc2c3d6f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/empty-with-base.html @@ -0,0 +1,27 @@ +<!doctype html> +<meta charset=utf-8> +<title>Script src with an empty URL</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<base href=unreachable.js> +<div id=log></div> +<script> +async_test(function(t) { + window.unreachable = this.unreached_func("Should not load unreachable.js"); + var queued = false; + var script = document.createElement("script"); + script.onerror = this.step_func_done(function(ev) { + assert_equals(ev.type, "error"); + assert_false(ev.bubbles, "bubbles"); + assert_false(ev.cancelable, "cancelable"); + assert_true(ev.isTrusted, "isTrusted"); + assert_equals(ev.target, script); + assert_true(ev instanceof Event, "instanceof Event"); + assert_class_string(ev, "Event"); + assert_true(queued, "event should not be dispatched synchronously"); + }); + script.setAttribute("src", ""); + document.body.appendChild(script); + queued = true; +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/empty.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/empty.html new file mode 100644 index 000000000..d127f1eb3 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/empty.html @@ -0,0 +1,32 @@ +<!doctype html> +<meta charset=utf-8> +<title>Script src with an empty URL</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +// For a better error message in case the UA tries to load "" (which resolves +// to this document). +setup({ + "allow_uncaught_exception": true, +}); +async_test(function(t) { + window.onerror = this.unreached_func("Should not get an error reported to " + + "the window before the script"); + var queued = false; + var script = document.createElement("script"); + script.onerror = this.step_func_done(function(ev) { + assert_equals(ev.type, "error"); + assert_false(ev.bubbles, "bubbles"); + assert_false(ev.cancelable, "cancelable"); + assert_true(ev.isTrusted, "isTrusted"); + assert_equals(ev.target, script); + assert_true(ev instanceof Event, "instanceof Event"); + assert_class_string(ev, "Event"); + assert_true(queued, "event should not be dispatched synchronously"); + }); + script.setAttribute("src", ""); + document.body.appendChild(script); + queued = true; +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/failure.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/failure.html new file mode 100644 index 000000000..b49e51740 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/failure.html @@ -0,0 +1,25 @@ +<!doctype html> +<meta charset=utf-8> +<title>Script src with an invalid URL</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<script> +async_test(function(t) { + var queued = false; + var script = document.createElement("script"); + script.onerror = this.step_func_done(function(ev) { + assert_equals(ev.type, "error"); + assert_false(ev.bubbles, "bubbles"); + assert_false(ev.cancelable, "cancelable"); + assert_true(ev.isTrusted, "isTrusted"); + assert_equals(ev.target, script); + assert_true(ev instanceof Event, "instanceof Event"); + assert_class_string(ev, "Event"); + assert_true(queued, "event should not be dispatched synchronously"); + }); + script.setAttribute("src", "//[]"); + document.body.appendChild(script); + queued = true; +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/unreachable.js b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/unreachable.js new file mode 100644 index 000000000..ca7fdba71 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/fetch-src/unreachable.js @@ -0,0 +1 @@ +unreachable(); diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/historical.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/historical.html new file mode 100644 index 000000000..1f1a91228 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/historical.html @@ -0,0 +1,53 @@ +<!doctype html> +<title>Historical script element features should not be supported</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +function t(property) { + test(function() { + assert_false(property in document.createElement('script')); + }, 'script.' + property + ' should not be supported'); +} +// added in https://github.com/whatwg/html/commit/69f83cf2eacf4543860ccb7abab0ff5bb1e8b594 +// removed in https://github.com/whatwg/html/commit/1a0b5e8377d59462e05a5cffda4b8592324a2785 +t('onbeforescriptexecute'); +t('onafterscriptexecute'); + +var t_onbeforescriptexecute_attr = async_test('onbeforescriptexecute content attribute should not be supported'); +var t_onafterscriptexecute_attr = async_test('onafterscriptexecute content attribute should not be supported'); +var t_beforescriptexecute_event = async_test(function() { + addEventListener('beforescriptexecute', this.step_func(function() { + assert_unreached(); + }), true); +}, 'beforescriptexecute event should not be supported'); +var t_afterscriptexecute_event = async_test(function() { + addEventListener('afterscriptexecute', this.step_func(function() { + assert_unreached(); + }), true); +}, 'afterscriptexecute event should not be supported'); + +var a = false; + +onload = function() { + t_onbeforescriptexecute_attr.step(function() { + assert_true(a); + this.done(); + }); + t_onafterscriptexecute_attr.step(function() { + assert_true(a); + this.done(); + }); + t_beforescriptexecute_event.step(function() { + assert_true(a); + this.done(); + }); + t_afterscriptexecute_event.step(function() { + assert_true(a); + this.done(); + }); +}; +</script> +<script onbeforescriptexecute="t_onbeforescriptexecute_attr.step(function() { assert_unreached(); });" + onafterscriptexecute="t_onafterscriptexecute_attr.step(function() { assert_unreached(); });"> +a = true; +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/load-event.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/load-event.html new file mode 100644 index 000000000..25c2ddf3e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/load-event.html @@ -0,0 +1,24 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#execute-the-script-block"> +<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"> + +<script> +"use strict"; + +async_test(function(t) { + window.scriptExecuting = function () { + setTimeout(t.step_func_done(() => { + assert_equals(window.onloadHappened, undefined); + }), 0); + }; +}, "load events should not be fired for inline scripts"); +</script> + + +<script onload="window.onloadHappened = true;"> +"use strict"; +window.scriptExecuting(); +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/log.py b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/log.py new file mode 100644 index 000000000..6803bb3e4 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/log.py @@ -0,0 +1,13 @@ +import time + +def main(request, response): + response.headers.append("Content-Type", "text/javascript") + try: + script_id = int(request.GET.first("id")) + delay = int(request.GET.first("sec")) + except: + response.set_error(400, "Invalid parameter") + + time.sleep(int(delay)) + + return "log('%s')" % script_id diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/resources/cross-origin.py b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/resources/cross-origin.py new file mode 100644 index 000000000..f8e05d966 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/resources/cross-origin.py @@ -0,0 +1,10 @@ +def main(request, response): + headers = [("Content-Type", "text/javascript")] + milk = request.cookies.first("milk", None) + + if milk is None: + return headers, "var included = false;" + elif milk.value == "yes": + return headers, "var included = true;" + + return headers, "var included = false;" diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-charset-01.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-charset-01.html new file mode 100644 index 000000000..c5ac0d0a6 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-charset-01.html @@ -0,0 +1,89 @@ +<!DOCTYPE html> +<head> + <meta charset="utf-8"> + <title>Script @type: unknown parameters</title> + <link rel="author" title="askalski" href="github.com/askalski"> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#scriptingLanguages"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <div id="log"></div> + + <!-- "Step1" tests --> + <!-- charset is set incorrectly via Content Type "text/javascript;charset=utf-8" in response + which has priority before a correct setting in "charset" attribute of script tag. + --> + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript%3Bcharset=utf-8" charset="windows-1250"> + </script> + <script> + test(function() { + //these strings should not match, since the file charset is set incorrectly + assert_not_equals(window.getSomeString(), "śćążź"); + }); + </script> + <!-- charset is set correctly via Content Type "text/javascript;charset=utf-8" in response + which has priority before a incorrect setting in "charset" attribute of script tag. + --> + + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript%3Bcharset=windows-1250" charset="utf-8"> + </script> + <script> + //the charset is set correctly via Content Type "text/javascript;charset=windows-1250" in respones + test(function() { + assert_equals(window.getSomeString(), "śćążź"); + }); + </script> + + <!-- end of step1 tests, now step2 tests --> + <!-- in this case, the response's Content Type does not bring charset information. + Second step takes block character encoding if available.--> + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript" charset="utf-8"> + </script> + <script> + test(function() { + //these strings should not match, since the file charset is set incorrectly in "charset" tag of <script> above + assert_not_equals(window.getSomeString(), "śćążź"); + }); + </script> + <!-- charset is set correctly via Content Type "text/javascript;charset=utf-8" in response + which has priority before a incorrect setting in "charset" attribute of script tag. + --> + + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript" charset="windows-1250"> + </script> + <script> + //the charset is set correctly via content attribute in <script> above + test(function() { + assert_equals(window.getSomeString(), "śćążź"); + }); + </script> + + <!-- end of step2 tests, now step3 tests --> + <!-- in this case, neither response's Content Type nor charset attribute bring correct charset information. + Third step takes this document's character encoding (declared correctly as UTF-8).--> + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript"> + </script> + <script> + test(function() { + //these strings should not match, since the tested file is in windows-1250, and document is utf-8 + assert_not_equals(window.getSomeString(), "śćążź"); + }); + </script> + + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-utf8.js&ct=text/javascript"> + </script> + <script> + //these strings should match, both document and tested file are utf-8 + test(function() { + assert_equals(window.getSomeString(), "śćążź"); + }); + </script> + + <!-- the last portion of tests (step4) are in file script-charset-02.html + +</head> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-charset-02.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-charset-02.html new file mode 100644 index 000000000..77a015bb7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-charset-02.html @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<head> + <!-- TODO: + askalski: while this test pass, it does not test anything now. + It should test, whether with no document.charset set in any way, the + external scripts will get decoded using utf-8 as fallback character encoding. + It seems like utf-8 is also a fallback encoding to html (my guess), so + the part of the code I was attempting to test is never reached. + --> + <title>Script @type: unknown parameters</title> + <link rel="author" title="askalski" href="github.com/askalski"> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#scriptingLanguages"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <div id="log"></div> + + <!-- test of step4, which is taking utf-8 as fallback --> + <!-- in this case, neither response's Content Type nor charset attribute bring correct charset information. + Furthermore, document's encoding is not set.--> + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript"> + </script> + <script> + test(function() { + //these strings should not match, since the tested file is in windows-1250, and fallback is defined as utf-8 + assert_not_equals(window.getSomeString().length, 5); + }); + </script> + + <script type="text/javascript" + src="serve-with-content-type.py?fn=external-script-utf8.js&ct=text/javascript"> + </script> + <script> + //these strings should match, since fallback utf-8 is the correct setting. + test(function() { + assert_equals(window.getSomeString().length, 5); + }); + </script> + +</head> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-charset-03.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-charset-03.html new file mode 100644 index 000000000..4ff4cc6b0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-charset-03.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<head> +<meta charset="utf-8"> +<title>Script changing @charset</title> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#scriptingLanguages"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +async_test(function() { + var s = document.createElement("script"); + s.src = "external-script-windows1250.js"; + s.charset = "windows-1250"; + document.body.appendChild(s); + s.charset = "utf-8"; + window.onload = this.step_func_done(function() { + assert_equals(window.getSomeString(), "\u015b\u0107\u0105\u017c\u017a"); + }); +}) +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-crossorigin-network.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-crossorigin-network.html new file mode 100644 index 000000000..488dd4488 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-crossorigin-network.html @@ -0,0 +1,49 @@ +<!doctype html> +<meta charset="utf-8"> +<title>HTMLScriptElement: crossorigin attribute network test</title> +<link rel="author" title="KiChjang" href="mailto:kungfukeith11@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#cors-settings-attribute"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<body> + <script type="text/javascript"> + var test1 = async_test(document.title + "1"); + var test2 = async_test(document.title + "2"); + var test3 = async_test(document.title + "3"); + + var script1 = document.createElement("script"); + script1.src = "resources/cross-origin.py"; + script1.crossOrigin = "use-credentials"; + var script2 = document.createElement("script"); + script2.src = "resources/cross-origin.py"; + script2.crossOrigin = "gibberish"; + var script3 = document.createElement("script"); + script3.src = "resources/cross-origin.py"; + + document.cookie = "milk=yes"; + document.body.appendChild(script1); + script1.onload = function() { + test1.step(function() { + assert_true(included, "credentials should be included in script request"); + test1.done(); + }); + }; + + document.body.appendChild(script2); + script2.onload = function() { + test2.step(function() { + assert_true(included, "invalid values should default to include credentials due to response tainting"); + test2.done(); + }); + }; + + document.body.appendChild(script3); + script3.onload = function() { + test3.step(function() { + assert_true(included, "missing value should default to include credentials"); + test3.done(); + }); + }; + </script> +</body> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-crossorigin.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-crossorigin.html new file mode 100644 index 000000000..52857a08e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-crossorigin.html @@ -0,0 +1,39 @@ +<!doctype html> +<meta charset="utf-8"> +<title>HTMLScriptElement: crossOrigin IDL attribute</title> +<link rel="author" title="KiChjang" href="mailto:kungfukeith11@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#cors-settings-attribute"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script id="script1"></script> +<script id="script2" crossorigin=""></script> +<script id="script3" crossorigin="foo"></script> +<script id="script4" crossorigin="anonymous"></script> +<script id="script5" crossorigin="use-credentials"></script> +<script> +test(function() { + var script1 = document.getElementById("script1"); + var script2 = document.getElementById("script2"); + var script3 = document.getElementById("script3"); + var script4 = document.getElementById("script4"); + var script5 = document.getElementById("script5"); + + assert_equals(script1.crossOrigin, null, "Missing value default should be null"); + assert_equals(script2.crossOrigin, "anonymous", "Empty string should map to anonymous"); + assert_equals(script3.crossOrigin, "anonymous", "Invalid value default should be anonymous"); + assert_equals(script4.crossOrigin, "anonymous", "anonymous should be parsed correctly"); + assert_equals(script5.crossOrigin, "use-credentials", "use-credentials should be parsed correctly"); + + script1.crossOrigin = "bar"; + assert_equals(script1.crossOrigin, "anonymous", "Setting to invalid value would default to anonymous"); + + script2.crossOrigin = null; + assert_equals(script2.crossOrigin, null, "Resetting to null should work"); + + script4.crossOrigin = "use-credentials"; + assert_equals(script4.crossOrigin, "use-credentials", "Switching from anonymous to use-credentials should work"); + + script5.crossOrigin = "anonymous"; + assert_equals(script5.crossOrigin, "anonymous", "Switching from use-credentials to anonymous should work"); +}, document.title); +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-for-event-xhtml.xhtml b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-for-event-xhtml.xhtml new file mode 100644 index 000000000..69c4ef1f8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-for-event-xhtml.xhtml @@ -0,0 +1,22 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <title>Scripts with for and event attributes</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> +</head> +<body> + <div id="log"></div> + <script> + var run = false; + </script> + <script for="window" event="bar"> + // This script should not run, but should not cause a parse error either. + run = true; + </script> + <script> + test(function() { + assert_false(run, "Script was unexpectedly run.") + }, "Scripts with for and event attributes should not run.") + </script> +</body> +</html> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-for-event.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-for-event.html new file mode 100644 index 000000000..552ea7041 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-for-event.html @@ -0,0 +1,93 @@ +<!DOCTYPE html> +<title>Scripts with for and event attributes</title> +<link rel="author" title="Matheus Kerschbaum" href="mailto:matjk7@gmail.com"> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#prepare-a-script"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var expected = [ + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + true, + true, + false, + true, + true, +]; +var run = expected.map(function() { return false }); +</script> +<script for="wİndow" event="onload"> +run[0] = true; +</script> +<script for="window" event="onload x"> +run[1] = true; +</script> +<script for="window" event="onload(x"> +run[2] = true; +</script> +<script for="window" event="onload(x)"> +run[3] = true; +</script> +<script for="window" event="onclick"> +run[4] = true; +</script> +<script for="" event="onload"> +run[5] = true; +</script> +<script for="window" event=""> +run[6] = true; +</script> +<script for="" event=""> +run[7] = true; +</script> +<script for=" window" event="onload"> +run[8] = true; +</script> +<script for="window " event="onload"> +run[9] = true; +</script> +<script for="window" event=" onload"> +run[10] = true; +</script> +<script for="window" event="onload "> +run[11] = true; +</script> +<script for=" window " event=" onload "> +run[12] = true; +</script> +<script for=" window " event=" onload() "> +run[13] = true; +</script> +<script for="object" event="handler"> +run[14] = true; +</script> +<script event="handler"> +run[15] = true; +</script> +<script for="object"> +run[16] = true; +</script> +<script> +test(function() { + for (var i = 0; i < run.length; ++i) { + test(function() { + var script = document.querySelectorAll("script[for], script[event]")[i]; + assert_equals(run[i], expected[i], + "script for=" + format_value(script.getAttribute("for")) + + " event=" + format_value(script.getAttribute("event"))); + }, "Script " + i); + } +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-language-type.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-language-type.html new file mode 100644 index 000000000..b94834c83 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-language-type.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<title>Script: combinations of @type and @language</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#prepare-a-script"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var run = false; +</script> +<script type="" language="foo"> +run = true; +</script> +<script> +test(function() { + assert_equals(run, true); +}, "A script with empty type should run"); +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-languages-01.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-languages-01.html new file mode 100644 index 000000000..f2f2724df --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-languages-01.html @@ -0,0 +1,24 @@ +<!DOCTYPE html> +<title>Script @type: unknown parameters</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#scriptingLanguages"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<div id="test"> +<script type="text/javascript;charset=UTF-8"> +test(function() { + assert_unreached("'charset' should have prevented this script from executing."); +}) +</script> +<script type="text/javascript;x-test=abc"> +test(function() { + assert_unreached("'x-test' should have prevented this script from executing."); +}) +</script> +</div> +<script> +test(function() { + assert_true(true) +}) +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-languages-02.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-languages-02.html new file mode 100644 index 000000000..69613e510 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-languages-02.html @@ -0,0 +1,98 @@ +<!DOCTYPE html> +<title>Script @type: JavaScript types</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#scriptingLanguages"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +function testAttribute(attr, val, shouldRun) { + test(function() { + assert_false(ran, "ran variable not reset"); + var script = document.createElement("script"); + script.setAttribute(attr, val); + script.textContent = "ran = true;" + document.body.appendChild(script); + assert_equals(ran, shouldRun); + }, "Script should" + (shouldRun ? "" : "n't") + " run with " + attr + "=" + format_value(val)); + ran = false +} +function testType(type) { + testAttribute("type", type, true); +} +function testLanguage(lang) { + testAttribute("language", lang, true); +} +function testTypeIgnored(type) { + testAttribute("type", type, false); +} +function testLanguageIgnored(lang) { + testAttribute("language", lang, false); +} +var application = [ + "ecmascript", + "javascript", + "x-ecmascript", + "x-javascript" +]; +var text = [ + "ecmascript", + "javascript", + "javascript1.0", + "javascript1.1", + "javascript1.2", + "javascript1.3", + "javascript1.4", + "javascript1.5", + "jscript", + "livescript", + "x-ecmascript", + "x-javascript" +]; +var spaces = [" ", "\t", "\n", "\r", "\f"]; + +var ran = false; + +// Type attribute + +testType(""); +testTypeIgnored(" "); + +application.map(function(t) { return "application/" + t; }).forEach(testType); +application.map(function(t) { return ("application/" + t).toUpperCase(); }).forEach(testType); + +spaces.forEach(function(s) { + application.map(function(t) { return "application/" + t + s; }).forEach(testType); + application.map(function(t) { return s + "application/" + t; }).forEach(testType); +}) + +application.map(function(t) { return "application/" + t + "\0"; }).forEach(testTypeIgnored); +application.map(function(t) { return "application/" + t + "\0foo"; }).forEach(testTypeIgnored); + +text.map(function(t) { return "text/" + t; }).forEach(testType); +text.map(function(t) { return ("text/" + t).toUpperCase(); }).forEach(testType); + +spaces.forEach(function(s) { + text.map(function(t) { return "text/" + t + s; }).forEach(testType); + text.map(function(t) { return s + "text/" + t; }).forEach(testType); +}) + +text.map(function(t) { return "text/" + t + "\0"; }).forEach(testTypeIgnored); +text.map(function(t) { return "text/" + t + "\0foo"; }).forEach(testTypeIgnored); + +// Language attribute + +testLanguage(""); +testLanguageIgnored(" "); + +text.forEach(testLanguage); +text.map(function(t) { return t.toUpperCase(); }).forEach(testLanguage); + +text.map(function(t) { return t + " "; }).forEach(testLanguageIgnored); +text.map(function(t) { return " " + t; }).forEach(testLanguageIgnored); +text.map(function(t) { return t + "xyz"; }).forEach(testLanguageIgnored); +text.map(function(t) { return "xyz" + t; }).forEach(testLanguageIgnored); + +text.map(function(t) { return t + "\0"; }).forEach(testLanguageIgnored); +text.map(function(t) { return t + "\0foo"; }).forEach(testLanguageIgnored); +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-noembed-noframes-iframe.xhtml b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-noembed-noframes-iframe.xhtml new file mode 100644 index 000000000..8dd9ceb9a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-noembed-noframes-iframe.xhtml @@ -0,0 +1,36 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>Script inside noembed, noframes and iframe</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +</head> +<body> +<div id="log"></div> +<script> +var run = []; +</script> +<div id="test"> +<noembed> +<script> +run.push("noembed"); +</script> +</noembed> +<noframes> +<script> +run.push("noframes"); +</script> +</noframes> +<iframe> +<script> +run.push("iframe"); +</script> +</iframe> +</div> +<script> +test(function() { + assert_array_equals(run, ["noembed", "noframes", "iframe"], "Haven't run."); +}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-executed-after-shutdown-child.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-executed-after-shutdown-child.html new file mode 100644 index 000000000..2f3ce2368 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-executed-after-shutdown-child.html @@ -0,0 +1,12 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Script is not executed after script thread is shutdown</title> +<script> +onload = function() { + script_executed = parent.script_executed; + s = document.createElement('script'); + s.type = 'text/javascript'; + s.src = 'script-not-executed-after-shutdown.js?pipe=trickle(d3)'; + document.body.appendChild(s); +}; +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-executed-after-shutdown.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-executed-after-shutdown.html new file mode 100644 index 000000000..704e8ed36 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-executed-after-shutdown.html @@ -0,0 +1,18 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Script is not executed after script thread is shutdown</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<iframe id="testiframe" src="script-not-executed-after-shutdown-child.html"></iframe> +<script> +async_test(function(t) { + window.script_executed = t.unreached_func("script executed in removed iframe"); + let iframe = document.getElementById("testiframe"); + iframe.onload = function() { + iframe.parentNode.removeChild(iframe); + }; + setTimeout(function() { + t.done(); + }, 5000); +}); +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-executed-after-shutdown.js b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-executed-after-shutdown.js new file mode 100644 index 000000000..ccdf14c0c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-executed-after-shutdown.js @@ -0,0 +1 @@ +script_executed(); diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-found-not-executed-2.py b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-found-not-executed-2.py new file mode 100644 index 000000000..53caed7c0 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-found-not-executed-2.py @@ -0,0 +1,4 @@ +def main(request, response): + headers = [("Content-Type", "text/javascript")] + body = "test2_token = \"script executed\";" + return 200, headers, body diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-found-not-executed.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-found-not-executed.html new file mode 100644 index 000000000..44ad30b01 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-found-not-executed.html @@ -0,0 +1,19 @@ +<!doctype html> +<meta charset="utf-8"> +<title></title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script>var test1_token = "script not executed";</script> +<script src="script-not-found-not-executed.py"></script> +<script> +test(function(){ + assert_equals(test1_token, "script not executed"); +}, "Script that 404"); +</script> +<script>var test2_token = "script not executed";</script> +<script src="script-not-found-not-executed-2.py"></script> +<script> +test(function(){ + assert_equals(test2_token, "script executed"); +}, "Script that does not 404"); +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-found-not-executed.py b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-found-not-executed.py new file mode 100644 index 000000000..7722bd3f2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-not-found-not-executed.py @@ -0,0 +1,4 @@ +def main(request, response): + headers = [("Content-Type", "text/javascript")] + body = "test1_token = \"script executed\";" + return 404, headers, body diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-onerror-insertion-point-1.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-onerror-insertion-point-1.html new file mode 100644 index 000000000..0fe39b11a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-onerror-insertion-point-1.html @@ -0,0 +1,12 @@ +<!doctype html> +<meta charset=utf-8> +<title>Test that the insertion point is defined in the error event of a parser-inserted script that actually started a fetch (but just had it fail).</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script> + var t = async_test(""); + var writeDone = t.step_func_done(function(text) { + assert_equals(text, "Some text"); + }); +</script> +<iframe src="support/script-onerror-insertion-point-1-helper.html"></iframe> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-onerror-insertion-point-2.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-onerror-insertion-point-2.html new file mode 100644 index 000000000..6d3f3ef09 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-onerror-insertion-point-2.html @@ -0,0 +1,13 @@ +<!doctype html> +<meta charset=utf-8> +<title>Test that the insertion point is not defined in the error event of a + parser-inserted script that has an unparseable URL</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script> + var t = async_test(""); + var writeDone = t.step_func_done(function(text) { + assert_equals(text, "text"); + }); +</script> +<iframe src="support/script-onerror-insertion-point-2-helper.html"></iframe> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-onload-insertion-point.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-onload-insertion-point.html new file mode 100644 index 000000000..ce3ddeee6 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-onload-insertion-point.html @@ -0,0 +1,12 @@ +<!doctype html> +<meta charset=utf-8> +<title>Test that the insertion point is defined in the load event of a parser-inserted script.</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script> + var t = async_test(""); + var writeDone = t.step_func_done(function(text) { + assert_equals(text, "Some text"); + }); +</script> +<iframe src="support/script-onload-insertion-point-helper.html"></iframe> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-onload-string.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-onload-string.html new file mode 100644 index 000000000..85f2d4dcf --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-onload-string.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<title>Script: setting onload to a string</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +test(function() { + var s = document.createElement("script"); + assert_equals(s.onload, null); + var dummy = function() {}; + s.onload = dummy; + assert_equals(s.onload, dummy); + s.onload = "w('load DOM appended')"; + assert_equals(s.onload, null); +}, "Setting onload to a string should convert to null."); +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-text-xhtml.xhtml b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-text-xhtml.xhtml new file mode 100644 index 000000000..33a4635db --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-text-xhtml.xhtml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>HTMLScriptElement.text</title> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-script-text"/> +<script src="/resources/testharness.js"/> +<script src="/resources/testharnessreport.js"/> +</head> +<body> +<div id="log"></div> +<script> +<x>7;</x> +<![CDATA[ + var x = "y"; +]]> +</script> +<script> +var script; +setup(function() { + script = document.body.getElementsByTagName("script")[0]; +}) +test(function() { + assert_equals(script.text, '\n\n\n var x = "y";\n\n') + assert_equals(script.textContent, '\n7;\n\n var x = "y";\n\n') +}, "Getter with CDATA section") +</script> +</body> +</html> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-text.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-text.html new file mode 100644 index 000000000..6e8647224 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/script-text.html @@ -0,0 +1,72 @@ +<!doctype html> +<meta charset=utf-8> +<title>HTMLScriptElement.text</title> +<link rel=help href="https://html.spec.whatwg.org/multipage/#dom-script-text"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +var script; +setup(function() { + script = document.createElement("script") + script.appendChild(document.createComment("COMMENT")) + script.appendChild(document.createTextNode(" TEXT ")) + script.appendChild(document.createProcessingInstruction("P", "I")) + script.appendChild(document.createElement("a")) + .appendChild(document.createTextNode("ELEMENT")) +}) + +test(function() { + assert_equals(script.text, " TEXT ") + assert_equals(script.textContent, " TEXT ELEMENT") +}, "Getter") + +test(function() { + script.text = " text " + assert_equals(script.text, " text ") + assert_equals(script.textContent, " text ") + assert_equals(script.firstChild.nodeType, Node.TEXT_NODE) + assert_equals(script.firstChild.data, " text ") + assert_equals(script.firstChild, script.lastChild) + assert_array_equals(script.childNodes, [script.firstChild]) +}, "Setter (non-empty string)") + +test(function() { + script.text = "" + assert_equals(script.text, "") + assert_equals(script.textContent, "") + assert_equals(script.firstChild, null) +}, "Setter (empty string)") + +test(function() { + script.text = null + assert_equals(script.text, "null") + assert_equals(script.textContent, "null") + assert_equals(script.firstChild.nodeType, Node.TEXT_NODE) + assert_equals(script.firstChild.data, "null") + assert_equals(script.firstChild, script.lastChild) +}, "Setter (null)") + +test(function() { + script.text = undefined + assert_equals(script.text, "undefined") + assert_equals(script.textContent, "undefined") + assert_equals(script.firstChild.nodeType, Node.TEXT_NODE) + assert_equals(script.firstChild.data, "undefined") + assert_equals(script.firstChild, script.lastChild) +}, "Setter (undefined)") + +test(function() { + var s = document.createElement("script"); + var text = document.createTextNode("one"); + s.appendChild(text); + + assert_equals(s.firstChild, text); + assert_equals(text.nodeValue, "one"); + + s.text = "two"; + assert_not_equals(s.firstChild, text); + assert_equals(text.nodeValue, "one"); + assert_equals(s.firstChild.nodeValue, "two"); +}, "Setter (text node reuse)") +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/scripting-enabled.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/scripting-enabled.html new file mode 100644 index 000000000..a2671a78f --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/scripting-enabled.html @@ -0,0 +1,16 @@ +<!doctype html> +<meta charset="utf-8"> +<title>JS is disabled on documents created without a browsing context</title> +<link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-n-script"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +test(function(t) { + var doc = document.implementation.createHTMLDocument(); + window.fail_test = t.unreached_func('should not have been called'); + + var script = doc.createElement('script'); + script.textContent = 'fail_test();'; + doc.documentElement.appendChild(script); +}, 'script on document returned by createHTMLDocument should not execute'); +</script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/serve-with-content-type.py b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/serve-with-content-type.py new file mode 100644 index 000000000..7cfe6f4ce --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/serve-with-content-type.py @@ -0,0 +1,15 @@ +import os + +def main(request, response): + directory = os.path.dirname(__file__) + + try: + file_name = request.GET.first("fn") + content_type = request.GET.first("ct") + with open(os.path.join(directory, file_name), "rb") as fh: + content = fh.read() + + response.headers.set("Content-Type", content_type) + response.content = content + except: + response.set_error(400, "Not enough parameters or file not found") diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/support/script-onerror-insertion-point-1-helper.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/support/script-onerror-insertion-point-1-helper.html new file mode 100644 index 000000000..d9b0c84ca --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/support/script-onerror-insertion-point-1-helper.html @@ -0,0 +1,2 @@ +Some <script src="nosuchscripthere.js" + onerror="document.write('text'); parent.writeDone(document.documentElement.textContent)"></script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/support/script-onerror-insertion-point-2-helper.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/support/script-onerror-insertion-point-2-helper.html new file mode 100644 index 000000000..7a1739815 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/support/script-onerror-insertion-point-2-helper.html @@ -0,0 +1,2 @@ +Some <script src="http://this is not parseable" + onerror="document.write('text'); parent.writeDone(document.documentElement.textContent)"></script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/support/script-onload-insertion-point-helper.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/support/script-onload-insertion-point-helper.html new file mode 100644 index 000000000..f0236b4fb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/support/script-onload-insertion-point-helper.html @@ -0,0 +1,2 @@ +Some <script src="script-onload-insertion-point-helper.js" + onload="document.write('xt'); parent.writeDone(document.documentElement.textContent)"></script> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/support/script-onload-insertion-point-helper.js b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/support/script-onload-insertion-point-helper.js new file mode 100644 index 000000000..8a96a0b78 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/support/script-onload-insertion-point-helper.js @@ -0,0 +1 @@ +document.write("te"); |