mirror of
https://github.com/servo/servo.git
synced 2025-06-24 00:54:32 +01:00
Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255
This commit is contained in:
parent
b2a5225831
commit
1a81b18b9f
12321 changed files with 544385 additions and 6 deletions
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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"
|
||||
}
|
||||
]
|
|
@ -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
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue