aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element
diff options
context:
space:
mode:
Diffstat (limited to 'tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element')
m---------tests/wpt/web-platform-tests0
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/.gitkeep0
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_001.htm18
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_002.htm31
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_003.htm39
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_004.htm37
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_005.htm39
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_006.htm45
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_007.htm48
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_008.htm47
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_009.htm25
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_010.htm54
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_011.htm19
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/contains.json18
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/log.py13
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-before-after-events.html55
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-for-event.html93
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-for-event.xhtml22
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-language-type.html18
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-languages-01.html24
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-languages-02.html98
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-noembed-noframes-iframe.xhtml36
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-onload-string.html17
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text.html53
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text.xhtml28
25 files changed, 877 insertions, 0 deletions
diff --git a/tests/wpt/web-platform-tests b/tests/wpt/web-platform-tests
deleted file mode 160000
-Subproject 29dfb8944e535d439ca94cf7d1b1d9138a8ad11
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/.gitkeep b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/.gitkeep
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/.gitkeep
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_001.htm b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_001.htm
new file mode 100644
index 00000000000..370152683b9
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_002.htm b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_002.htm
new file mode 100644
index 00000000000..e1850ff6e16
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_003.htm b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_003.htm
new file mode 100644
index 00000000000..b9a854c6bbf
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_004.htm b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_004.htm
new file mode 100644
index 00000000000..7908b757a3d
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_005.htm b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_005.htm
new file mode 100644
index 00000000000..4519d72346e
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_006.htm b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_006.htm
new file mode 100644
index 00000000000..86eb99897ab
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_007.htm b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_007.htm
new file mode 100644
index 00000000000..8df0fba37d0
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_008.htm b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_008.htm
new file mode 100644
index 00000000000..73529cc3182
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_009.htm b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_009.htm
new file mode 100644
index 00000000000..501edda065a
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_010.htm b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_010.htm
new file mode 100644
index 00000000000..959a8aa274d
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_011.htm b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/async_011.htm
new file mode 100644
index 00000000000..d80e463cee5
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/contains.json b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/contains.json
new file mode 100644
index 00000000000..e31ce400312
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/log.py b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/log.py
new file mode 100644
index 00000000000..6803bb3e405
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-before-after-events.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-before-after-events.html
new file mode 100644
index 00000000000..4cd77250ed6
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-before-after-events.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>script beforescriptexecute/afterscriptexecute events</title>
+<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
+<link rel=help href="https://html.spec.whatwg.org/multipage/#the-script-element">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+ var t1 = async_test("'beforescriptexecute'/'afterscriptexecute' events have been fired"),
+ t2 = async_test("default prevented 'beforescriptexecute' event aborts script execution"),
+ a = false,
+ b = false;
+
+ var before = function(e) {
+ b = true;
+ test(function(){
+ assert_true(e.isTrusted);
+ assert_true(e.bubbles);
+ assert_true(e.cancelable);
+ }, "'beforescriptexecute' event is trusted, bubbles and is cancelable");
+ };
+
+ var after = function(e) {
+ a = true;
+ test(function(){
+ assert_true(e.isTrusted);
+ assert_true(e.bubbles);
+ assert_false(e.cancelable);
+ }, "'afterscriptexecute' event is trusted, bubbles and isn't cancelable");
+ };
+
+ var prevent_default = function(e) {
+ t2.step(function() {
+ e.preventDefault();
+ assert_true(e.defaultPrevented);
+ });
+ };
+
+ document.body.onload = function() {
+ t1.step(function() {
+ assert_true(a && b);
+ });
+ t1.done();
+ t2.done();
+ };
+</script>
+<script onbeforescriptexecute=before(event) onafterscriptexecute=after(event)>
+ document.querySelector("script");
+</script>
+<script onbeforescriptexecute=prevent_default(event)>
+ t2.step(function() {
+ assert_unreached("script execution not aborted by default prevented 'beforescriptexecute' event");
+ });
+</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-for-event.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-for-event.html
new file mode 100644
index 00000000000..552ea7041a3
--- /dev/null
+++ b/tests/wpt/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&#x130;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="&#xa0;window" event="onload">
+run[8] = true;
+</script>
+<script for="window&#xa0;" event="onload">
+run[9] = true;
+</script>
+<script for="window" event="&#xa0;onload">
+run[10] = true;
+</script>
+<script for="window" event="onload&#xa0;">
+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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-for-event.xhtml b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-for-event.xhtml
new file mode 100644
index 00000000000..69c4ef1f810
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-for-event.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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-language-type.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-language-type.html
new file mode 100644
index 00000000000..b94834c83dd
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-languages-01.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-languages-01.html
new file mode 100644
index 00000000000..f2f2724df5a
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-languages-02.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-languages-02.html
new file mode 100644
index 00000000000..69613e5104f
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-noembed-noframes-iframe.xhtml b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-noembed-noframes-iframe.xhtml
new file mode 100644
index 00000000000..8dd9ceb9a62
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-onload-string.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-onload-string.html
new file mode 100644
index 00000000000..85f2d4dcfaf
--- /dev/null
+++ b/tests/wpt/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/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text.html
new file mode 100644
index 00000000000..e32f8402427
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text.html
@@ -0,0 +1,53 @@
+<!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)")
+</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text.xhtml b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text.xhtml
new file mode 100644
index 00000000000..33a4635db37
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text.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>