Bug 1118722 - Update web-platform-tests to revision a4f1782fd9e93746364ed219e60a8c2bafd0910e, a=testonly

--HG--
rename : testing/web-platform/tests/progress-events/tests/submissions/Samsung/resources/img.jpg => testing/web-platform/tests/XMLHttpRequest/resources/img.jpg
rename : testing/web-platform/tests/webmessaging/without-ports/009.html => testing/web-platform/tests/common/failing-test.html
This commit is contained in:
James Graham 2015-01-07 13:12:56 +00:00
parent 824ff4e989
commit 5f119200fc
443 changed files with 113091 additions and 4133 deletions

View File

@ -1,9 +1,10 @@
node_modules
scratch
*#
*.py[co]
*.sw[po]
*~
*#
MANIFEST.json
\#*
config.json
MANIFEST.json
node_modules
scratch
testharness_runner.html

View File

@ -10,3 +10,9 @@
path = tools/pywebsocket
url = https://github.com/w3c/pywebsocket.git
ignore = dirty
[submodule "html5lib"]
path = tools/html5lib
url = https://github.com/html5lib/html5lib-python.git
[submodule "tools/six"]
path = tools/six
url = https://github.com/jgraham/six.git

View File

@ -1,7 +1,5 @@
language: python
python:
- "2.7"
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install: pip install html5lib
# command to run tests, e.g. python setup.py test
script: python tools/scripts/lint.py

View File

@ -0,0 +1,30 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>IDBObjectStore.get() - throw TransactionInactiveError on aborted transaction </title>
<link rel="author" title="YuichiNukiyama" href="https://github.com/YuichiNukiyama">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>
var db,
t = async_test();
var open_rq = createdb(t);
open_rq.onupgradeneeded = function(e) {
db = e.target.result;
db.createObjectStore("store", { keyPath: "key" })
}
open_rq.onsuccess = function (e) {
var store = db.transaction("store")
.objectStore("store");
store.transaction.abort();
assert_throws("TransactionInactiveError", function () {
store.get(1);
}, "throw TransactionInactiveError on aborted transaction.");
t.done();
}
</script>
<div id="log"></div>

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>IDBObjectStore.get() - throw DataError when using invalid key </title>
<link rel="author" title="YuichiNukiyama" href="https://github.com/YuichiNukiyama">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<script>
var db,
t = async_test();
var open_rq = createdb(t);
open_rq.onupgradeneeded = function(e) {
db = e.target.result;
db.createObjectStore("store", { keyPath: "key" })
}
open_rq.onsuccess = function(e) {
var store = db.transaction("store")
.objectStore("store")
assert_throws("DataError", function () {
store.get(null)
}, "throw DataError when using invalid key.");
t.done();
}
</script>
<div id="log"></div>

View File

@ -166,6 +166,8 @@ interface Window { };
interface WorkerUtils { };
interface Event { };
interface EventTarget { };
</script>
@ -200,4 +202,3 @@ setup(function() {
idlArray.test();
});
</script>

View File

@ -176,6 +176,7 @@ everything that we can.
If you wish to contribute actively, you're very welcome to join the
public-test-infra@w3.org mailing list (low traffic) by
[signing up to our mailing list](mailto:public-test-infra-request@w3.org?subject=subscribe).
The mailing list is [archived][mailarchive].
Join us on irc #testing ([irc.w3.org][ircw3org], port 6665). The channel
is [archived][ircarchive].
@ -183,6 +184,29 @@ is [archived][ircarchive].
[contributing]: https://github.com/w3c/web-platform-tests/blob/master/CONTRIBUTING.md
[ircw3org]: https://www.w3.org/wiki/IRC
[ircarchive]: http://krijnhoetmer.nl/irc-logs/testing/
[mailarchive]: http://lists.w3.org/Archives/Public/public-test-infra/
Adding command-line scripts ("tools" subdirs)
----------------------------------------------------
Sometimes you may want to add a script to the repository that's meant to be used from the
command line, not from a browser (e.g., a script for generating test files). If you want to
ensure (e.g., or security reasons) that such scripts won't be handled by the HTTP server,
but will instead only be usable from the command line, then place them in either:
* the `tools` subdir at the root of the repository, or
* the `tools` subdir at the root of any top-level directory in the repository which
contains the tests the script is meant to be used with
Any files in those `tools` directories won't be handled by the HTTP server; instead the
server will return a 404 if a user navigates to the URL for a file within them.
If you want to add a script for use with a particular set of tests but there isn't yet any
`tools` subdir at the root of a top-level directory in the repository containing those
tests, you can create a `tools` subdir at the root of that top-level directory and place
your scripts there.
For example, if you wanted to add a script for use with tests in the `notifications`
directory, create the `notifications/tools` subdir and put your script there.
Documentation
-------------

View File

@ -0,0 +1,30 @@
<!doctype html>
<html>
<head>
<title>ProgressEvent: security consideration</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://xhr.spec.whatwg.org/#security-considerations" data-tested-assertations="/following-sibling::p" />
<link rel="help" href="https://fetch.spec.whatwg.org/#http-fetch" data-tested-assertations="/following-sibling::ol[1]/li[3]/ol[1]/li[6]" />
</head>
<body>
<div id="log"></div>
<script>
async_test(function() {
var xhr = new XMLHttpRequest();
xhr.onprogress = this.unreached_func("MUST NOT dispatch progress event.");
xhr.onload = this.unreached_func("MUST NOT dispatch load event.");
xhr.onerror = this.step_func(function(pe) {
assert_equals(pe.type, "error");
assert_equals(pe.loaded, 0, "loaded is zero.");
assert_false(pe.lengthComputable, "lengthComputable is false.");
assert_equals(pe.total, 0, "total is zero.");
});
xhr.onloadend = this.step_func_done();
xhr.open("GET", "http://{{host}}:{{ports[http][1]}}/XMLHttpRequest/resources/img.jpg", true);
xhr.send(null);
})
</script>
</body>
</html>

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<title>navigator.getBattery() - navigator.getBattery()'s returnvalue is Promise<BatteryManager>. </title>
<link rel="author" title="YuichiNukiyama" href="https://github.com/YuichiNukiyama">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function returnBattery() {
return navigator.getBattery();
}
promise_test(function () {
return returnBattery()
.then(function (result) {
assert_class_string(result, "BatteryManager", "getBattery should return BatteryManager Object.");
});
}, "navigator.getBattery() return BatteryManager");
</script>
<div id="log"></div>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Failing test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_unreached("Expected failure");
});
</script>

View File

@ -0,0 +1,46 @@
<!DOCTYPE HTML>
<html>
<head>
<title>img element src attribute must match src list.</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<h1>img element src attribute must match src list.</h1>
<p>
<div id='log'></div>
<script type="text/javascript">
var t1 = async_test("img-src for relative path should load.");
var t2 = async_test("img-src from unapproved domains should not load");
var t3 = async_test("img-src from approved domains should load");
</script>
<img src='/content-security-policy/support/pass.png'
onerror='t1.step(function() { assert_unreached("The img should have loaded."); t1.done() });'
onload='t1.done();'>
<img src='http://www1.web-platform.test/content-security-policy/support/fail.png'
onerror='t2.done();'
onload='t2.step(function() { assert_unreached("Image from unapproved domain was loaded."); t2.done()} );'>
<div id='t3'></div>
<script>
var t3img = document.createElement('img');
t3img.onerror = function() {t3.step(function() { assert_unreached(); t3.done();})}
t3img.onload = function() {t3.done();}
t3img.src = location.protocol + '//www.' + location.hostname + ':' + location.port +
'/content-security-policy/support/pass.png';
var t3div = document.getElementById('t3');
t3div.appendChild(t3img);
var report = document.createElement('script');
report.src = '../support/checkReport.sub.js?reportField=violated-directive&reportValue=img-src%20%27self%27%20www.' + location.hostname + (location.port ? ':' + location.port : '');
t3div.appendChild(report);
</script>
</body>
</html>

View File

@ -0,0 +1,6 @@
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache
Set-Cookie: img-src-4_1={{$id:uuid()}}; Path=/content-security-policy/img-src/
Content-Security-Policy: img-src 'self' www.{{host}}:{{ports[http][0]}}; report-uri ../support/report.py?op=put&reportID={{$id}}

View File

@ -0,0 +1,44 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Video element src attribute must match src list - positive test</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<h1>Video element src attribute must match src list - positive test</h1>
<div id='log'></div>
<script>
var src_test = async_test("In-policy async video src");
var source_test = async_test("In-policy async video source element");
function media_loaded(t) {
t.done();
}
function media_error_handler(t) {
t.step( function () {
assert_unreached("Media error handler should be triggered for non-allowed domain.");
});
t.done();
}
</script>
<video id="videoObject" width="320" height="240" controls
onloadeddata="media_loaded(source_test)">
<source id="videoSourceObject"
type="video/mp4"
onerror="media_error_handler(source_test)"
src="/media/white.mp4">
</video>
<video id="videoObject2" width="320" height="240" controls
onerror="media_error_handler(src_test)"
onloadeddata="media_loaded(src_test)"
src="/media/white.mp4">
<script async defer src="../support/checkReport.sub.js?reportExists=false">
</script>
</body>
</html>

View File

@ -0,0 +1,6 @@
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache
Set-Cookie: media-src-7_1={{$id:uuid()}}; Path=/content-security-policy/media-src/
Content-Security-Policy: script-src * 'unsafe-inline'; media-src 'self'; report-uri ../support/report.py?op=put&reportID={{$id}}

View File

@ -0,0 +1,54 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Video element src attribute must match src list - negative test</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<h1>Video element src attribute must match src list - negative test</h1>
<div id='log'></div>
<script>
var src_test = async_test("Disallowed async video src");
var source_test = async_test("Disallowed async video source element");
// we assume tests are run from 'hostname' and 'www.hostname' or 'www2.hostname' is a valid alias
var mediaURL = location.protocol +
"//www2." +
location.hostname +
":" +
location.port +
"/media/white.mp4";
function media_loaded(t) {
t.step( function () {
assert_unreached("Media error handler should be triggered for non-allowed domain.");
});
t.done();
}
function media_error_handler(t) {
t.done();
}
</script>
<video id="videoObject" width="320" height="240" controls
onloadeddata="media_loaded(source_test)">
<source id="videoSourceObject"
type="video/mp4"
onerror="media_error_handler(source_test)">
</video>
<video id="videoObject2" width="320" height="240" controls
onerror="media_error_handler(src_test)"
onloadeddata="media_loaded(src_test)">
<script>
document.getElementById("videoSourceObject").src = mediaURL;
document.getElementById("videoObject2").src = mediaURL;
</script>
<script async defer src='../support/checkReport.sub.js?reportField=violated-directive&reportValue=media-src%20%27self%27'></script>
</body>
</html>

View File

@ -0,0 +1,6 @@
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache
Set-Cookie: media-src-7_1_2={{$id:uuid()}}; Path=/content-security-policy/media-src/
Content-Security-Policy: script-src * 'unsafe-inline'; media-src 'self'; report-uri ../support/report.py?op=put&reportID={{$id}}

View File

@ -0,0 +1,44 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Audio element src attribute must match src list - positive test</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<h1>Audio element src attribute must match src list - positive test</h1>
<div id='log'></div>
<script>
var src_test = async_test("In-policy audio src");
var source_test = async_test("In-policy audio source element");
function media_loaded(t) {
t.done();
}
function media_error_handler(t) {
t.step( function () {
assert_unreached("Media error handler should be triggered for non-allowed domain.");
});
t.done();
}
</script>
<audio id="audioObject" width="320" height="240" controls
onloadeddata="media_loaded(source_test)">
<source id="audioSourceObject"
type="audio/mpeg"
onerror="media_error_handler(source_test)"
src="/media/sound_5.mp3">
</audio>
<audio id="audioObject2" width="320" height="240" controls
onerror="media_error_handler(src_test)"
onloadeddata="media_loaded(src_test)"
src="/media/sound_5.mp3">
<script async defer src="../support/checkReport.sub.js?reportExists=false">
</script>
</body>
</html>

View File

@ -0,0 +1,6 @@
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache
Set-Cookie: media-src-7_2={{$id:uuid()}}; Path=/content-security-policy/media-src/
Content-Security-Policy: script-src * 'unsafe-inline'; media-src 'self'; report-uri ../support/report.py?op=put&reportID={{$id}}

View File

@ -0,0 +1,54 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Audio element src attribute must match src list - negative test</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<h1>Audio element src attribute must match src list - negative test</h1>
<div id='log'></div>
<script>
var src_test = async_test("Disallaowed audio src");
var source_test = async_test("Disallowed audio source element");
// we assume tests are run from 'hostname' and 'www.hostname' or 'www2.hostname' is a valid alias
var mediaURL = location.protocol +
"//www2." +
location.hostname +
":" +
location.port +
"/media/sound_5.mp3";
function media_loaded(t) {
t.step( function () {
assert_unreached("Media error handler should be triggered for non-allowed domain.");
});
t.done();
}
function media_error_handler(t) {
t.done();
}
</script>
<audio id="audioObject" width="320" height="240" controls
onloadeddata="media_loaded(source_test)">
<source id="audioSourceObject"
type="audio/mpeg"
onerror="media_error_handler(source_test)">
</audio>
<audio id="audioObject2" width="320" height="240" controls
onerror="media_error_handler(src_test)"
onloadeddata="media_loaded(src_test)">
<script>
document.getElementById("audioSourceObject").src = mediaURL;
document.getElementById("audioObject2").src = mediaURL;
</script>
<script async defer src='../support/checkReport.sub.js?reportField=violated-directive&reportValue=media-src%20%27self%27'></script>
</body>
</html>

View File

@ -0,0 +1,6 @@
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache
Set-Cookie: media-src-7_2_2={{$id:uuid()}}; Path=/content-security-policy/media-src/
Content-Security-Policy: script-src * 'unsafe-inline'; media-src 'self'; report-uri ../support/report.py?op=put&reportID={{$id}}

View File

@ -0,0 +1,53 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Video track src attribute must match src list - positive test</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<h1>Video track src attribute must match src list - positive test</h1>
<div id='log'></div>
<script>
var source_test = async_test("In-policy track element");
var trackURL = location.protocol +
"//www." +
location.hostname +
":" +
location.port +
"/media/foo.vtt";
function media_loaded(t) {
t.done();
}
function media_error_handler(t) {
t.step( function () {
assert_unreached("Error handler called for allowed track source.");
});
t.done();
}
</script>
<video id="videoObject" width="320" height="240" controls
onloadeddata="media_loaded(source_test)" crossorigin>
<source id="audioSourceObject"
type="audio/mpeg"
src="/media/white.mp4">
<track id="trackObject"
kind="subtitles"
srclang="en"
label="English"
onerror="media_error_handler(source_test)">
</video>
<script>
document.getElementById("trackObject").src = trackURL;
</script>
<script async defer src="../support/checkReport.sub.js?reportExists=false">
</script>
</body>
</html>

View File

@ -0,0 +1,6 @@
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache
Set-Cookie: media-src-7_3={{$id:uuid()}}; Path=/content-security-policy/media-src/
Content-Security-Policy: script-src * 'unsafe-inline'; media-src 'self' www.{{host}}:{{ports[http][0]}}; report-uri ../support/report.py?op=put&reportID={{$id}}

View File

@ -0,0 +1,53 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Video track src attribute must match src list - negative test</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<h1>Video track src attribute must match src list - negative test</h1>
<div id='log'></div>
<script>
var source_test = async_test("Disallowed track element");
var trackURL = location.protocol +
"//www." +
location.hostname +
":" +
location.port +
"/media/foo.vtt";
function media_loaded(t) {
t.step( function () {
assert_unreached("Disllowed track source loaded.");
});
t.done();
}
function media_error_handler(t) {
t.done();
}
</script>
<video id="videoObject" width="320" height="240" controls
onloadeddata="media_loaded(source_test)" crossorigin>
<source id="audioSourceObject"
type="audio/mpeg"
src="/media/white.mp4">
<track id="trackObject"
kind="subtitles"
srclang="en"
label="English"
onerror="media_error_handler(source_test)">
</video>
<script>
document.getElementById("trackObject").src = trackURL;
</script>
<script async defer src="../support/checkReport.sub.js?reportField=violated-directive&reportValue=media-src%20%27self%27">
</script>
</body>
</html>

View File

@ -0,0 +1,6 @@
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache
Set-Cookie: media-src-7_3_2={{$id:uuid()}}; Path=/content-security-policy/media-src/
Content-Security-Policy: script-src * 'unsafe-inline'; media-src 'self'; report-uri ../support/report.py?op=put&reportID={{$id}}

View File

@ -0,0 +1 @@
var dataScriptRan = false;

View File

@ -0,0 +1,3 @@
test(function () {
assert_true(dataScriptRan, "data script ran");
}, "Verify that data: as script src runs with this policy");

View File

@ -0,0 +1,21 @@
(function ()
{
var test = new async_test("test inline worker");
var workerSource = document.getElementById('inlineWorker');
var blob = new Blob([workerSource.textContent]);
// can I create a new script tag like this? ack...
var url = window.URL.createObjectURL(blob);
var worker = new Worker(url);
worker.addEventListener('message', function(e) {
test.step(function () {
assert_not_equals(e.data, 'fail', 'inline script ran');
test.done();
})
}, false);
worker.postMessage('');
})();

View File

@ -0,0 +1,27 @@
<!DOCTYPE HTML>
<html>
<head>
<title>data: as script src should not run with a policy that doesn't specify data: as an allowed source</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<h1>data: as script src should not run with a policy that doesn't specify data: as an allowed source</h1>
<div id='log'></div>
<script>
var dataScriptRan = false;
</script>
<!-- This is our test case, but we don't expect it to actually execute if CSP is working. -->
<script src="data:text/javascript;charset=utf-8;base64,ZGF0YVNjcmlwdFJhbiA9IHRydWU7"></script>
<script>
test(function () {
assert_false(dataScriptRan, "data script ran");
}, "Verify that data: as script src doesn't run with this policy");
</script>
<script async defer src='../support/checkReport.sub.js?reportField=violated-directive&reportValue=default-src%20%27self%27+%27unsafe-inline%27'></script>
</body>
</html>

View File

@ -0,0 +1,6 @@
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache
Set-Cookie: script-src-1_10={{$id:uuid()}}; Path=/content-security-policy/script-src/
Content-Security-Policy: default-src 'self' 'unsafe-inline'; report-uri ../support/report.py?op=put&reportID={{$id}}

View File

@ -0,0 +1,20 @@
<!DOCTYPE HTML>
<html>
<head>
<title>data: as script src should run with a policy that specifies data: as an allowed source but not 'unsafe-inline'</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<h1>data: as script src should run with a policy that specifies data: as an allowed source but not 'unsafe-inline'</h1>
<div id='log'></div>
<script src="10_1_support_1.js"></script>
<script src="data:text/javascript;charset=utf-8;base64,ZGF0YVNjcmlwdFJhbiA9IHRydWU7"></script>
<script src="10_1_support_2.js"></script>
<script async defer src='../support/checkReport.sub.js?reportExists=false'></script>
</body>
</html>

View File

@ -0,0 +1,6 @@
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache
Set-Cookie: script-src-1_10_1={{$id:uuid()}}; Path=/content-security-policy/script-src/
Content-Security-Policy: script-src 'self' data:; report-uri ../support/report.py?op=put&reportID={{$id}}

View File

@ -0,0 +1,22 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Worker created from inline text and loaded via blob URI should not run with policy default-src *</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<h1>Worker created from inline text and loaded via blob URI should not run with policy default-src *</h1>
<div id='log'></div>
<script id="inlineWorker" type="app/worker">
addEventListener('message', function() {
postMessage('fail');
}, false);
</script>
<script src="buildInlineWorker.js"></script>
<script async defer src='../support/checkReport.sub.js?reportField=violated-directive&reportValue=default-src%20*'></script>
</body>
</html>

View File

@ -0,0 +1,6 @@
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache
Set-Cookie: script-src-1_9={{$id:uuid()}}; Path=/content-security-policy/script-src/
Content-Security-Policy: default-src *; report-uri ../support/report.py?op=put&reportID={{$id}}

View File

@ -0,0 +1 @@
#content {margin-left: 2px;}

View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<head>
<title>href of link with rel=stylesheet must be in src list</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script>
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.setAttribute('rel', 'stylesheet');
link.setAttribute('type', 'text/css');
link.setAttribute('href', location.protocol +
'//www1.' +
location.hostname +
':' +
location.port +
'/content-security-policy/style-src/3_3.css');
head.appendChild(link);
onload = function doTest() {
test(function() {
var text = document.getElementById("content");
assert_true(getComputedStyle(text).marginLeft != "2px", "Style sheet loaded from origin not in style-src directive should be blocked");
});
}
</script>
</head>
<body>
<h1>href of link with rel=stylesheet must be in src list</h1>
<div id='log'></div>
<div id="content">This text should not have a margin-left of 2</div>
<script async defer src='../support/checkReport.sub.js?reportField=violated-directive&reportValue=style-src%20%27self%27'></script>
</body>
</html>

View File

@ -0,0 +1,6 @@
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0, false
Pragma: no-cache
Set-Cookie: style-src-3_3={{$id:uuid()}}; Path=/content-security-policy/style-src/
Content-Security-Policy: script-src 'self' 'unsafe-inline'; style-src 'self'; report-uri ../support/report.py?op=put&reportID={{$id}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 759 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -1,8 +0,0 @@
<!DOCTYPE html>
<html lang=en>
<meta charset=UTF-8>
<title>Web tests</title>
<link rel=stylesheet href=/resources/test-runner/runner.css>
<script src=/resources/test-runner/runner.js></script>
<p><button value=./>Run tests in this dir</button>

View File

@ -140,6 +140,32 @@ support directory:
* a cat
* a 4-part picture
## Tools
Sometimes you may want to add a script to the repository that's meant
to be used from the command line, not from a browser (e.g., a script
for generating test files). If you want to ensure (e.g., or security
reasons) that such scripts won't be handled by the HTTP server, but
will instead only be usable from the command line, then place them
in either:
* the `tools` subdir at the root of the repository, or
* the `tools` subdir at the root of any top-level directory in the
repo which contains the tests the script is meant to be used with
Any files in those `tools` directories won't be handled by the HTTP
server; instead the server will return a 404 if a user navigates to
the URL for a file within them.
If you want to add a script for use with a particular set of tests
but there isn't yet any `tools` subdir at the root of a top-level
directory in the repository containing those tests, you can create
a `tools` subdir at the root of that top-level directory and place
your scripts there.
For example, if you wanted to add a script for use with tests in the
`notifications` directory, create the `notifications/tools` subdir
and put your script there.
## Style Rules
A number of style rules should be applied to the test file. These are
@ -148,7 +174,7 @@ new tests. Any of these rules may be broken if the test demands it:
* No trailing whitespace
* Use tabs rather than spaces for indentation
* Use spaces rather than tabs for indentation
* Use UNIX-style line endings (i.e. no CR characters at EOL).

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@ function isInterfaceNuked(name) {
var nukedInterfaces = [
"CDATASection",
"DOMConfiguration",
"DOMError",
"DOMErrorHandler",
"DOMImplementationList",
"DOMImplementationSource",
@ -39,7 +40,6 @@ function isNukedFromDocument(name) {
var documentNuked = [
"createCDATASection",
"createEntityReference",
"inputEncoding",
"xmlEncoding",
"xmlStandalone",
"xmlVersion",

View File

@ -39,12 +39,6 @@ exception DOMException {
unsigned short code;
};
[Constructor(DOMString name, optional DOMString message = "")]
interface DOMError {
readonly attribute DOMString name;
readonly attribute DOMString message;
};
[Constructor(DOMString type, optional EventInit eventInitDict),
Exposed=Window,Worker]
interface Event {
@ -258,6 +252,7 @@ interface Document : Node {
readonly attribute DOMString origin;
readonly attribute DOMString compatMode;
readonly attribute DOMString characterSet;
readonly attribute DOMString inputEncoding; // legacy alias of .characterSet
readonly attribute DOMString contentType;
readonly attribute DocumentType? doctype;

View File

@ -102,8 +102,8 @@ test(function() {
test(function() {
var doc = document.implementation.createDocument(namespace, qualifiedName, doctype)
assert_equals(doc.compatMode, "CSS1Compat")
// XXX Spec says "utf-8", browsers do "UTF-8".
assert_equals(doc.characterSet.toUpperCase(), "UTF-8")
assert_equals(doc.characterSet, "UTF-8")
assert_equals(doc.inputEncoding, "UTF-8")
assert_equals(doc.contentType, "application/xml")
assert_equals(doc.URL, "about:blank")
assert_equals(doc.documentURI, "about:blank")

View File

@ -68,8 +68,8 @@ test(function() {
assert_equals(doc.URL, "about:blank");
assert_equals(doc.documentURI, "about:blank");
assert_equals(doc.compatMode, "CSS1Compat");
// XXX Spec says "utf-8", browsers do "UTF-8".
assert_equals(doc.characterSet.toUpperCase(), "UTF-8");
assert_equals(doc.characterSet, "UTF-8");
assert_equals(doc.inputEncoding, "UTF-8");
assert_equals(doc.contentType, "text/html");
assert_equals(doc.createElement("DIV").localName, "div");
}, "createHTMLDocument(): metadata")

View File

@ -0,0 +1,166 @@
function test_getElementsByTagName(context, element) {
// TODO: getElementsByTagName("*")
test(function() {
assert_false(context.getElementsByTagName("html") instanceof NodeList,
"Should not return a NodeList")
assert_true(context.getElementsByTagName("html") instanceof HTMLCollection,
"Should return an HTMLCollection")
}, "Interfaces")
test(function() {
var firstCollection = context.getElementsByTagName("html"),
secondCollection = context.getElementsByTagName("html")
assert_true(firstCollection !== secondCollection ||
firstCollection === secondCollection)
}, "Caching is allowed")
test(function() {
var l = context.getElementsByTagName("nosuchtag")
l[5] = "foopy"
assert_equals(l[5], undefined)
assert_equals(l.item(5), null)
}, "Shouldn't be able to set unsigned properties on a HTMLCollection (non-strict mode)")
test(function() {
var l = context.getElementsByTagName("nosuchtag")
assert_throws(new TypeError(), function() {
"use strict";
l[5] = "foopy"
})
assert_equals(l[5], undefined)
assert_equals(l.item(5), null)
}, "Shouldn't be able to set unsigned properties on a HTMLCollection (strict mode)")
test(function() {
var l = context.getElementsByTagName("nosuchtag")
var fn = l.item;
assert_equals(fn, HTMLCollection.prototype.item);
l.item = "pass"
assert_equals(l.item, "pass")
assert_equals(HTMLCollection.prototype.item, fn);
}, "Should be able to set expando shadowing a proto prop (item)")
test(function() {
var l = context.getElementsByTagName("nosuchtag")
var fn = l.namedItem;
assert_equals(fn, HTMLCollection.prototype.namedItem);
l.namedItem = "pass"
assert_equals(l.namedItem, "pass")
assert_equals(HTMLCollection.prototype.namedItem, fn);
}, "Should be able to set expando shadowing a proto prop (namedItem)")
test(function() {
var t = element.appendChild(document.createElement("pre"));
t.id = "x";
this.add_cleanup(function() {element.removeChild(t)});
var list = context.getElementsByTagName('pre');
var pre = list[0];
assert_equals(pre.id, "x");
assert_equals(list['x'], pre);
assert_true('x' in list, "'x' in list");
assert_true(list.hasOwnProperty('x'), "list.hasOwnProperty('x')");
assert_array_equals(Object.getOwnPropertyNames(list).sort(), ["0", "x"]);
var desc = Object.getOwnPropertyDescriptor(list, '0');
assert_equals(typeof desc, "object", "descriptor should be an object");
assert_true(desc.enumerable, "desc.enumerable");
assert_true(desc.configurable, "desc.configurable");
desc = Object.getOwnPropertyDescriptor(list, 'x');
assert_equals(typeof desc, "object", "descriptor should be an object");
assert_false(desc.enumerable, "desc.enumerable");
assert_true(desc.configurable, "desc.configurable");
}, "hasOwnProperty, getOwnPropertyDescriptor, getOwnPropertyNames")
test(function() {
assert_equals(document.createElementNS("http://www.w3.org/1999/xhtml", "i").localName, "i") // Sanity
var t = element.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "I"))
this.add_cleanup(function() {element.removeChild(t)})
assert_equals(t.localName, "I")
assert_equals(t.tagName, "I")
assert_equals(context.getElementsByTagName("I").length, 0)
assert_equals(context.getElementsByTagName("i").length, 0)
}, "HTML element with uppercase tagName never matches in HTML Documents")
test(function() {
var t = element.appendChild(document.createElementNS("test", "st"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagName("st"), [t])
assert_array_equals(context.getElementsByTagName("ST"), [])
}, "Element in non-HTML namespace, no prefix, lowercase name")
test(function() {
var t = element.appendChild(document.createElementNS("test", "ST"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagName("ST"), [t])
assert_array_equals(context.getElementsByTagName("st"), [])
}, "Element in non-HTML namespace, no prefix, uppercase name")
test(function() {
var t = element.appendChild(document.createElementNS("test", "te:st"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagName("st"), [t])
assert_array_equals(context.getElementsByTagName("ST"), [])
}, "Element in non-HTML namespace, prefix, lowercase name")
test(function() {
var t = element.appendChild(document.createElementNS("test", "te:ST"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagName("ST"), [t])
assert_array_equals(context.getElementsByTagName("st"), [])
assert_array_equals(context.getElementsByTagName("te:st"), [])
assert_array_equals(context.getElementsByTagName("te:ST"), [])
}, "Element in non-HTML namespace, prefix, uppercase name")
test(function() {
var t = element.appendChild(document.createElement("aÇ"))
this.add_cleanup(function() {element.removeChild(t)})
assert_equals(t.localName, "aÇ")
assert_array_equals(context.getElementsByTagName("AÇ"), [t], "All uppercase input")
assert_array_equals(context.getElementsByTagName("aÇ"), [t], "Ascii lowercase input")
assert_array_equals(context.getElementsByTagName("aç"), [], "All lowercase input")
}, "Element in HTML namespace, no prefix, non-ascii characters in name")
test(function() {
var t = element.appendChild(document.createElementNS("test", "AÇ"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagName("AÇ"), [t])
assert_array_equals(context.getElementsByTagName("aÇ"), [])
assert_array_equals(context.getElementsByTagName("aç"), [])
}, "Element in non-HTML namespace, non-ascii characters in name")
test(function() {
var t = element.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "test:aÇ"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagName("AÇ"), [t], "All uppercase input")
assert_array_equals(context.getElementsByTagName("aÇ"), [t], "Ascii lowercase input")
assert_array_equals(context.getElementsByTagName("aç"), [], "All lowercase input")
}, "Element in HTML namespace, prefix, non-ascii characters in name")
test(function() {
var t = element.appendChild(document.createElementNS("test", "test:AÇ"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagName("AÇ"), [t], "All uppercase input")
assert_array_equals(context.getElementsByTagName("aÇ"), [], "Ascii lowercase input")
assert_array_equals(context.getElementsByTagName("aç"), [], "All lowercase input")
}, "Element in non-HTML namespace, prefix, non-ascii characters in name")
test(function() {
var actual = context.getElementsByTagName("*");
var expected = [];
var get_elements = function(node) {
for (var i = 0; i < node.childNodes.length; i++) {
var child = node.childNodes[i];
if (child.nodeType === child.ELEMENT_NODE) {
expected.push(child);
get_elements(child);
}
}
}
get_elements(context);
assert_array_equals(actual, expected);
}, "getElementsByTagName('*')")
}

View File

@ -0,0 +1,128 @@
function test_getElementsByTagNameNS(context, element) {
test(function() {
assert_false(context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html") instanceof NodeList, "NodeList")
assert_true(context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html") instanceof HTMLCollection, "HTMLCollection")
var firstCollection = context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html"),
secondCollection = context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html")
assert_true(firstCollection !== secondCollection || firstCollection === secondCollection,
"Caching is allowed.")
})
test(function() {
var t = element.appendChild(document.createElementNS("test", "body"))
this.add_cleanup(function() {element.removeChild(t)})
var actual = context.getElementsByTagNameNS("*", "body");
var expected = [];
var get_elements = function(node) {
for (var i = 0; i < node.childNodes.length; i++) {
var child = node.childNodes[i];
if (child.nodeType === child.ELEMENT_NODE) {
if (child.localName == "body") {
expected.push(child);
}
get_elements(child);
}
}
}
get_elements(context);
assert_array_equals(actual, expected);
}, "getElementsByTagNameNS('*', 'body')")
test(function() {
assert_array_equals(context.getElementsByTagNameNS("", "*"), []);
var t = element.appendChild(document.createElementNS("", "body"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("", "*"), [t]);
}, "Empty string namespace")
test(function() {
var t = element.appendChild(document.createElementNS("test", "body"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("test", "body"), [t]);
}, "body element in test namespace, no prefix")
test(function() {
var t = element.appendChild(document.createElementNS("test", "test:body"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("test", "body"), [t]);
}, "body element in test namespace, prefix")
test(function() {
var t = element.appendChild(document.createElementNS("test", "BODY"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("test", "BODY"), [t]);
assert_array_equals(context.getElementsByTagNameNS("test", "body"), []);
}, "BODY element in test namespace, no prefix")
test(function() {
var t = element.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "abc"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "abc"), [t]);
assert_array_equals(context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "ABC"), []);
assert_array_equals(context.getElementsByTagNameNS("test", "ABC"), []);
}, "abc element in html namespace")
test(function() {
var t = element.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "ABC"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "abc"), []);
assert_array_equals(context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "ABC"), [t]);
}, "ABC element in html namespace")
test(function() {
var t = element.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "AÇ"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "AÇ"), [t]);
assert_array_equals(context.getElementsByTagNameNS("test", "aÇ"), []);
assert_array_equals(context.getElementsByTagNameNS("test", "aç"), []);
}, "AÇ, case sensitivity")
test(function() {
var t = element.appendChild(document.createElementNS("test", "test:BODY"))
this.add_cleanup(function() {element.removeChild(t)})
assert_array_equals(context.getElementsByTagNameNS("test", "BODY"), [t]);
assert_array_equals(context.getElementsByTagNameNS("test", "body"), []);
}, "BODY element in test namespace, prefix")
test(function() {
var t = element.appendChild(document.createElementNS("test", "test:test"))
this.add_cleanup(function() {element.removeChild(t)})
var actual = context.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "*");
var expected = [];
var get_elements = function(node) {
for (var i = 0; i < node.childNodes.length; i++) {
var child = node.childNodes[i];
if (child.nodeType === child.ELEMENT_NODE) {
if (child !== t) {
expected.push(child);
}
get_elements(child);
}
}
}
get_elements(context);
assert_array_equals(actual, expected);
}, "getElementsByTagNameNS('http://www.w3.org/1999/xhtml', '*')")
test(function() {
var actual = context.getElementsByTagNameNS("*", "*");
var expected = [];
var get_elements = function(node) {
for (var i = 0; i < node.childNodes.length; i++) {
var child = node.childNodes[i];
if (child.nodeType === child.ELEMENT_NODE) {
expected.push(child);
get_elements(child);
}
}
}
get_elements(context);
assert_array_equals(actual, expected);
}, "getElementsByTagNameNS('*', '*')")
test(function() {
assert_array_equals(context.getElementsByTagNameNS("**", "*"), []);
assert_array_equals(context.getElementsByTagNameNS(null, "0"), []);
assert_array_equals(context.getElementsByTagNameNS(null, "div"), []);
}, "Empty lists")
}

View File

@ -0,0 +1,18 @@
<!doctype html>
<meta charset=utf-8>
<title>Document.URL with redirect</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
async_test(function() {
var iframe = document.createElement("iframe");
iframe.src = "/common/redirect.py?location=/common/blank.html";
document.body.appendChild(iframe);
this.add_cleanup(function() { document.body.removeChild(iframe); });
iframe.onload = this.step_func_done(function() {
assert_equals(iframe.contentDocument.URL,
"http://{{host}}:{{ports[http][0]}}/common/blank.html");
});
})
</script>

View File

@ -1,5 +1,5 @@
<!doctype html>
<title>document.characterSet normalization tests</title>
<title>document.characterSet and inputEncoding normalization tests</title>
<link rel=author title="Aryeh Gregor" href=ayg@aryeh.name>
<meta name=timeout content=long>
<div id=log></div>
@ -20,7 +20,6 @@ var encodingMap = {
"utf-16",
"utf-16le",
"utf-16be",
"utf-16be",
],
"ibm866": [
"866",
@ -342,11 +341,23 @@ Object.keys(encodingMap).forEach(function(name) {
}
});
function expected_case(encoding_label) {
if (encoding_label === 'big5') {
return 'Big5';
}
if (encoding_label === 'shift_jis') {
return 'Shift_JIS';
}
return encoding_label.toUpperCase();
}
Object.keys(encodingMap).forEach(function(name) {
encodingMap[name].forEach(function(label) {
var iframe = document.createElement("iframe");
var t = async_test("Name " + format_value(name) +
" has label " + format_value(label));
" has label " + format_value(label) + " (characterSet)");
var t2 = async_test("Name " + format_value(name) +
" has label " + format_value(label) + " (inputEncoding)");
/*
iframe.src = "data:text/html,<!doctype html>" +
'<meta charset="' + label + '">';
@ -354,10 +365,14 @@ Object.keys(encodingMap).forEach(function(name) {
iframe.src = "encoding.py?label=" + label;
iframe.onload = function() {
t.step(function() {
assert_equals(iframe.contentDocument.characterSet.toLowerCase(), name);
assert_equals(iframe.contentDocument.characterSet, expected_case(name));
});
t2.step(function() {
assert_equals(iframe.contentDocument.inputEncoding, expected_case(name));
});
document.body.removeChild(iframe);
t.done();
t2.done();
};
document.body.appendChild(iframe);
});

View File

@ -31,8 +31,8 @@ test(function() {
assert_equals(doc.URL, "about:blank");
assert_equals(doc.documentURI, "about:blank");
assert_equals(doc.compatMode, "CSS1Compat");
// XXX Spec says "utf-8", browsers do "UTF-8".
assert_equals(doc.characterSet.toUpperCase(), "UTF-8");
assert_equals(doc.characterSet, "UTF-8");
assert_equals(doc.inputEncoding, "UTF-8");
assert_equals(doc.contentType, "application/xml");
assert_equals(doc.createElement("DIV").localName, "DIV");
}, "new Document(): metadata")

View File

@ -4,169 +4,8 @@
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-getelementsbytagname">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="Document-Element-getElementsByTagName.js"></script>
<div id="log"></div>
<pre id="x"></pre>
<script>
// TODO: getElementsByTagName("*")
test(function() {
assert_false(document.getElementsByTagName("html") instanceof NodeList,
"Should not return a NodeList")
assert_true(document.getElementsByTagName("html") instanceof HTMLCollection,
"Should return an HTMLCollection")
}, "Interfaces")
test(function() {
var firstCollection = document.getElementsByTagName("html"),
secondCollection = document.getElementsByTagName("html")
assert_true(firstCollection !== secondCollection ||
firstCollection === secondCollection)
}, "Caching is allowed")
test(function() {
var l = document.getElementsByTagName("nosuchtag")
l[5] = "foopy"
assert_equals(l[5], undefined)
assert_equals(l.item(5), null)
}, "Shouldn't be able to set unsigned properties on a HTMLCollection (non-strict mode)")
test(function() {
var l = document.getElementsByTagName("nosuchtag")
assert_throws(new TypeError(), function() {
"use strict";
l[5] = "foopy"
})
assert_equals(l[5], undefined)
assert_equals(l.item(5), null)
}, "Shouldn't be able to set unsigned properties on a HTMLCollection (strict mode)")
test(function() {
var l = document.getElementsByTagName("nosuchtag")
var fn = l.item;
assert_equals(fn, HTMLCollection.prototype.item);
l.item = "pass"
assert_equals(l.item, "pass")
assert_equals(HTMLCollection.prototype.item, fn);
}, "Should be able to set expando shadowing a proto prop (item)")
test(function() {
var l = document.getElementsByTagName("nosuchtag")
var fn = l.namedItem;
assert_equals(fn, HTMLCollection.prototype.namedItem);
l.namedItem = "pass"
assert_equals(l.namedItem, "pass")
assert_equals(HTMLCollection.prototype.namedItem, fn);
}, "Should be able to set expando shadowing a proto prop (namedItem)")
test(function() {
var list = document.getElementsByTagName('pre');
var pre = list[0];
assert_equals(pre.id, "x");
assert_equals(list['x'], pre);
assert_true('x' in list, "'x' in list");
assert_true(list.hasOwnProperty('x'), "list.hasOwnProperty('x')");
assert_array_equals(Object.getOwnPropertyNames(list).sort(), ["0", "x"]);
var desc = Object.getOwnPropertyDescriptor(list, '0');
assert_equals(typeof desc, "object", "descriptor should be an object");
assert_true(desc.enumerable, "desc.enumerable");
assert_true(desc.configurable, "desc.configurable");
desc = Object.getOwnPropertyDescriptor(list, 'x');
assert_equals(typeof desc, "object", "descriptor should be an object");
assert_false(desc.enumerable, "desc.enumerable");
assert_true(desc.configurable, "desc.configurable");
}, "hasOwnProperty, getOwnPropertyDescriptor, getOwnPropertyNames")
test(function() {
assert_equals(document.createElementNS("http://www.w3.org/1999/xhtml", "i").localName, "i") // Sanity
var t = document.body.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "I"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_equals(t.localName, "I")
assert_equals(t.tagName, "I")
assert_equals(document.getElementsByTagName("I").length, 0)
assert_equals(document.getElementsByTagName("i").length, 0)
assert_equals(document.body.getElementsByTagName("I").length, 0)
assert_equals(document.body.getElementsByTagName("i").length, 0)
}, "HTML element with uppercase tagName never matches in HTML Documents")
test(function() {
var t = document.body.appendChild(document.createElementNS("test", "st"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_array_equals(document.getElementsByTagName("st"), [t])
assert_array_equals(document.getElementsByTagName("ST"), [])
}, "Element in non-HTML namespace, no prefix, lowercase name")
test(function() {
var t = document.body.appendChild(document.createElementNS("test", "ST"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_array_equals(document.getElementsByTagName("ST"), [t])
assert_array_equals(document.getElementsByTagName("st"), [])
}, "Element in non-HTML namespace, no prefix, uppercase name")
test(function() {
var t = document.body.appendChild(document.createElementNS("test", "te:st"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_array_equals(document.getElementsByTagName("st"), [t])
assert_array_equals(document.getElementsByTagName("ST"), [])
}, "Element in non-HTML namespace, prefix, lowercase name")
test(function() {
var t = document.body.appendChild(document.createElementNS("test", "te:ST"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_array_equals(document.getElementsByTagName("ST"), [t])
assert_array_equals(document.getElementsByTagName("st"), [])
assert_array_equals(document.getElementsByTagName("te:st"), [])
assert_array_equals(document.getElementsByTagName("te:ST"), [])
}, "Element in non-HTML namespace, prefix, uppercase name")
test(function() {
var t = document.body.appendChild(document.createElement("aÇ"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_equals(t.localName, "aÇ")
assert_array_equals(document.getElementsByTagName("AÇ"), [t], "All uppercase input")
assert_array_equals(document.getElementsByTagName("aÇ"), [t], "Ascii lowercase input")
assert_array_equals(document.getElementsByTagName("aç"), [], "All lowercase input")
}, "Element in HTML namespace, no prefix, non-ascii characters in name")
test(function() {
var t = document.body.appendChild(document.createElementNS("test", "AÇ"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_array_equals(document.getElementsByTagName("AÇ"), [t])
assert_array_equals(document.getElementsByTagName("aÇ"), [])
assert_array_equals(document.getElementsByTagName("aç"), [])
}, "Element in non-HTML namespace, non-ascii characters in name")
test(function() {
var t = document.body.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "test:aÇ"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_array_equals(document.getElementsByTagName("AÇ"), [t], "All uppercase input")
assert_array_equals(document.getElementsByTagName("aÇ"), [t], "Ascii lowercase input")
assert_array_equals(document.getElementsByTagName("aç"), [], "All lowercase input")
}, "Element in HTML namespace, prefix, non-ascii characters in name")
test(function() {
var t = document.body.appendChild(document.createElementNS("test", "test:AÇ"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_array_equals(document.getElementsByTagName("AÇ"), [t], "All uppercase input")
assert_array_equals(document.getElementsByTagName("aÇ"), [], "Ascii lowercase input")
assert_array_equals(document.getElementsByTagName("aç"), [], "All lowercase input")
}, "Element in non-HTML namespace, prefix, non-ascii characters in name")
test(function() {
var actual = document.getElementsByTagName("*");
var expected = [];
var get_elements = function(node) {
for (var i = 0; i < node.childNodes.length; i++) {
var child = node.childNodes[i];
if (child.nodeType === child.ELEMENT_NODE) {
expected.push(child);
get_elements(child);
}
}
}
get_elements(document);
assert_array_equals(actual, expected);
}, "getElementsByTagName('*')")
test_getElementsByTagName(document, document.body);
</script>

View File

@ -4,133 +4,8 @@
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-getelementsbytagnamens">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="Document-Element-getElementsByTagNameNS.js"></script>
<div id="log"></div>
<script>
// TODO: Actual tests; wildcards.
test(function() {
assert_false(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html") instanceof NodeList, "NodeList")
assert_true(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html") instanceof HTMLCollection, "HTMLCollection")
var firstCollection = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html"),
secondCollection = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "html")
assert_true(firstCollection !== secondCollection || firstCollection === secondCollection,
"Caching is allowed.")
})
test(function() {
var t = document.body.appendChild(document.createElementNS("test", "body"))
this.add_cleanup(function() {document.body.removeChild(t)})
var actual = document.getElementsByTagNameNS("*", "body");
var expected = [];
var get_elements = function(node) {
for (var i = 0; i < node.childNodes.length; i++) {
var child = node.childNodes[i];
if (child.nodeType === child.ELEMENT_NODE) {
if (child.localName == "body") {
expected.push(child);
}
get_elements(child);
}
}
}
get_elements(document);
assert_array_equals(actual, expected);
}, "getElementsByTagNameNS('*', 'body')")
test(function() {
assert_array_equals(document.getElementsByTagNameNS("", "*"), []);
var t = document.body.appendChild(document.createElementNS("", "body"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_array_equals(document.getElementsByTagNameNS("", "*"), [t]);
}, "Empty string namespace")
test(function() {
var t = document.body.appendChild(document.createElementNS("test", "body"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_array_equals(document.getElementsByTagNameNS("test", "body"), [t]);
}, "body element in test namespace, no prefix")
test(function() {
var t = document.body.appendChild(document.createElementNS("test", "test:body"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_array_equals(document.getElementsByTagNameNS("test", "body"), [t]);
}, "body element in test namespace, prefix")
test(function() {
var t = document.body.appendChild(document.createElementNS("test", "BODY"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_array_equals(document.getElementsByTagNameNS("test", "BODY"), [t]);
assert_array_equals(document.getElementsByTagNameNS("test", "body"), []);
}, "BODY element in test namespace, no prefix")
test(function() {
var t = document.body.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "abc"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_array_equals(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "abc"), [t]);
assert_array_equals(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "ABC"), []);
assert_array_equals(document.getElementsByTagNameNS("test", "ABC"), []);
}, "abc element in html namespace")
test(function() {
var t = document.body.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "ABC"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_array_equals(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "abc"), []);
assert_array_equals(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "ABC"), [t]);
}, "ABC element in html namespace")
test(function() {
var t = document.body.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "AÇ"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_array_equals(document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "AÇ"), [t]);
assert_array_equals(document.getElementsByTagNameNS("test", "aÇ"), []);
assert_array_equals(document.getElementsByTagNameNS("test", "aç"), []);
}, "AÇ, case sensitivity")
test(function() {
var t = document.body.appendChild(document.createElementNS("test", "test:BODY"))
this.add_cleanup(function() {document.body.removeChild(t)})
assert_array_equals(document.getElementsByTagNameNS("test", "BODY"), [t]);
assert_array_equals(document.getElementsByTagNameNS("test", "body"), []);
}, "BODY element in test namespace, prefix")
test(function() {
var t = document.body.appendChild(document.createElementNS("test", "test:test"))
this.add_cleanup(function() {document.body.removeChild(t)})
var actual = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "*");
var expected = [];
var get_elements = function(node) {
for (var i = 0; i < node.childNodes.length; i++) {
var child = node.childNodes[i];
if (child.nodeType === child.ELEMENT_NODE) {
if (child !== t) {
expected.push(child);
}
get_elements(child);
}
}
}
get_elements(document);
assert_array_equals(actual, expected);
}, "getElementsByTagNameNS('http://www.w3.org/1999/xhtml', '*')")
test(function() {
var actual = document.getElementsByTagNameNS("*", "*");
var expected = [];
var get_elements = function(node) {
for (var i = 0; i < node.childNodes.length; i++) {
var child = node.childNodes[i];
if (child.nodeType === child.ELEMENT_NODE) {
expected.push(child);
get_elements(child);
}
}
}
get_elements(document);
assert_array_equals(actual, expected);
}, "getElementsByTagNameNS('*', '*')")
test(function() {
assert_array_equals(document.getElementsByTagNameNS("**", "*"), []);
assert_array_equals(document.getElementsByTagNameNS(null, "0"), []);
assert_array_equals(document.getElementsByTagNameNS(null, "div"), []);
}, "Empty lists")
test_getElementsByTagNameNS(document, document.body);
</script>

View File

@ -0,0 +1,30 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Element.getElementsByTagName</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-element-getelementsbytagname">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="Document-Element-getElementsByTagName.js"></script>
<div id="log"></div>
<script>
var element;
setup(function() {
element = document.createElement("div");
element.appendChild(document.createTextNode("text"));
var p = element.appendChild(document.createElement("p"));
p.appendChild(document.createElement("a"))
.appendChild(document.createTextNode("link"));
p.appendChild(document.createElement("b"))
.appendChild(document.createTextNode("bold"));
p.appendChild(document.createElement("em"))
.appendChild(document.createElement("u"))
.appendChild(document.createTextNode("emphasized"));
element.appendChild(document.createComment("comment"));
});
test_getElementsByTagName(element, element);
test(function() {
assert_array_equals(element.getElementsByTagName(element.localName), []);
}, "Matching the context object");
</script>

View File

@ -0,0 +1,37 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Element.getElementsByTagNameNS</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-element-getelementsbytagnamens">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="Document-Element-getElementsByTagNameNS.js"></script>
<div id="log"></div>
<script>
var element;
setup(function() {
element = document.createElement("div");
element.appendChild(document.createTextNode("text"));
var p = element.appendChild(document.createElement("p"));
p.appendChild(document.createElement("a"))
.appendChild(document.createTextNode("link"));
p.appendChild(document.createElement("b"))
.appendChild(document.createTextNode("bold"));
p.appendChild(document.createElement("em"))
.appendChild(document.createElement("u"))
.appendChild(document.createTextNode("emphasized"));
element.appendChild(document.createComment("comment"));
});
test_getElementsByTagNameNS(element, element);
test(function() {
assert_array_equals(element.getElementsByTagNameNS("*", element.localName), []);
}, "Matching the context object (wildcard namespace)");
test(function() {
assert_array_equals(
element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml",
element.localName),
[]);
}, "Matching the context object (specific namespace)");
</script>

View File

@ -0,0 +1 @@
<a name='c'>c</a>

View File

@ -30,4 +30,4 @@ function testIframe(iframe) {
t.done();
}
</script>
<iframe id=a src="data:text/html,<a name='c'>c</a>" onload="testIframe(this)"></iframe>
<iframe id=a src="Node-parentNode-iframe.html" onload="testIframe(this)"></iframe>

File diff suppressed because it is too large Load Diff

View File

@ -15,223 +15,223 @@ iframes in the DOM.
testDiv.parentNode.removeChild(testDiv);
function restoreIframe(iframe, i, j) {
// Most of this function is designed to work around the fact that Opera
// doesn't let you add a doctype to a document that no longer has one, in
// any way I can figure out. I eventually compromised on something that
// will still let Opera pass most tests that don't actually involve
// doctypes.
while (iframe.contentDocument.firstChild
&& iframe.contentDocument.firstChild.nodeType != Node.DOCUMENT_TYPE_NODE) {
iframe.contentDocument.removeChild(iframe.contentDocument.firstChild);
}
// Most of this function is designed to work around the fact that Opera
// doesn't let you add a doctype to a document that no longer has one, in
// any way I can figure out. I eventually compromised on something that
// will still let Opera pass most tests that don't actually involve
// doctypes.
while (iframe.contentDocument.firstChild
&& iframe.contentDocument.firstChild.nodeType != Node.DOCUMENT_TYPE_NODE) {
iframe.contentDocument.removeChild(iframe.contentDocument.firstChild);
}
while (iframe.contentDocument.lastChild
&& iframe.contentDocument.lastChild.nodeType != Node.DOCUMENT_TYPE_NODE) {
iframe.contentDocument.removeChild(iframe.contentDocument.lastChild);
}
while (iframe.contentDocument.lastChild
&& iframe.contentDocument.lastChild.nodeType != Node.DOCUMENT_TYPE_NODE) {
iframe.contentDocument.removeChild(iframe.contentDocument.lastChild);
}
if (!iframe.contentDocument.firstChild) {
// This will throw an exception in Opera if we reach here, which is why
// I try to avoid it. It will never happen in a browser that obeys the
// spec, so it's really just insurance. I don't think it actually gets
// hit by anything.
iframe.contentDocument.appendChild(iframe.contentDocument.implementation.createDocumentType("html", "", ""));
}
iframe.contentDocument.appendChild(referenceDoc.documentElement.cloneNode(true));
iframe.contentWindow.setupRangeTests();
iframe.contentWindow.testRangeInput = testRangesShort[i];
iframe.contentWindow.testNodeInput = testNodesShort[j];
iframe.contentWindow.run();
if (!iframe.contentDocument.firstChild) {
// This will throw an exception in Opera if we reach here, which is why
// I try to avoid it. It will never happen in a browser that obeys the
// spec, so it's really just insurance. I don't think it actually gets
// hit by anything.
iframe.contentDocument.appendChild(iframe.contentDocument.implementation.createDocumentType("html", "", ""));
}
iframe.contentDocument.appendChild(referenceDoc.documentElement.cloneNode(true));
iframe.contentWindow.setupRangeTests();
iframe.contentWindow.testRangeInput = testRangesShort[i];
iframe.contentWindow.testNodeInput = testNodesShort[j];
iframe.contentWindow.run();
}
function testInsertNode(i, j) {
var actualRange;
var expectedRange;
var actualNode;
var expectedNode;
var actualRoots = [];
var expectedRoots = [];
var actualRange;
var expectedRange;
var actualNode;
var expectedNode;
var actualRoots = [];
var expectedRoots = [];
var detached = false;
var detached = false;
domTests[i][j].step(function() {
restoreIframe(actualIframe, i, j);
restoreIframe(expectedIframe, i, j);
domTests[i][j].step(function() {
restoreIframe(actualIframe, i, j);
restoreIframe(expectedIframe, i, j);
actualRange = actualIframe.contentWindow.testRange;
expectedRange = expectedIframe.contentWindow.testRange;
actualNode = actualIframe.contentWindow.testNode;
expectedNode = expectedIframe.contentWindow.testNode;
actualRange = actualIframe.contentWindow.testRange;
expectedRange = expectedIframe.contentWindow.testRange;
actualNode = actualIframe.contentWindow.testNode;
expectedNode = expectedIframe.contentWindow.testNode;
try {
actualRange.collapsed;
} catch (e) {
detached = true;
}
try {
actualRange.collapsed;
} catch (e) {
detached = true;
}
assert_equals(actualIframe.contentWindow.unexpectedException, null,
"Unexpected exception thrown when setting up Range for actual insertNode()");
assert_equals(expectedIframe.contentWindow.unexpectedException, null,
"Unexpected exception thrown when setting up Range for simulated insertNode()");
assert_equals(typeof actualRange, "object",
"typeof Range produced in actual iframe");
assert_false(actualRange === null,
"Range produced in actual iframe was null");
assert_equals(typeof expectedRange, "object",
"typeof Range produced in expected iframe");
assert_false(expectedRange === null,
"Range produced in expected iframe was null");
assert_equals(typeof actualNode, "object",
"typeof Node produced in actual iframe");
assert_false(actualNode === null,
"Node produced in actual iframe was null");
assert_equals(typeof expectedNode, "object",
"typeof Node produced in expected iframe");
assert_false(expectedNode === null,
"Node produced in expected iframe was null");
assert_equals(actualIframe.contentWindow.unexpectedException, null,
"Unexpected exception thrown when setting up Range for actual insertNode()");
assert_equals(expectedIframe.contentWindow.unexpectedException, null,
"Unexpected exception thrown when setting up Range for simulated insertNode()");
assert_equals(typeof actualRange, "object",
"typeof Range produced in actual iframe");
assert_false(actualRange === null,
"Range produced in actual iframe was null");
assert_equals(typeof expectedRange, "object",
"typeof Range produced in expected iframe");
assert_false(expectedRange === null,
"Range produced in expected iframe was null");
assert_equals(typeof actualNode, "object",
"typeof Node produced in actual iframe");
assert_false(actualNode === null,
"Node produced in actual iframe was null");
assert_equals(typeof expectedNode, "object",
"typeof Node produced in expected iframe");
assert_false(expectedNode === null,
"Node produced in expected iframe was null");
// We want to test that the trees containing the ranges are equal, and
// also the trees containing the moved nodes. These might not be the
// same, if we're inserting a node from a detached tree or a different
// document.
//
// Detached ranges are always in the contentDocument.
if (detached) {
actualRoots.push(actualIframe.contentDocument);
expectedRoots.push(expectedIframe.contentDocument);
} else {
actualRoots.push(furthestAncestor(actualRange.startContainer));
expectedRoots.push(furthestAncestor(expectedRange.startContainer));
}
// We want to test that the trees containing the ranges are equal, and
// also the trees containing the moved nodes. These might not be the
// same, if we're inserting a node from a detached tree or a different
// document.
//
// Detached ranges are always in the contentDocument.
if (detached) {
actualRoots.push(actualIframe.contentDocument);
expectedRoots.push(expectedIframe.contentDocument);
} else {
actualRoots.push(furthestAncestor(actualRange.startContainer));
expectedRoots.push(furthestAncestor(expectedRange.startContainer));
}
if (furthestAncestor(actualNode) != actualRoots[0]) {
actualRoots.push(furthestAncestor(actualNode));
}
if (furthestAncestor(expectedNode) != expectedRoots[0]) {
expectedRoots.push(furthestAncestor(expectedNode));
}
if (furthestAncestor(actualNode) != actualRoots[0]) {
actualRoots.push(furthestAncestor(actualNode));
}
if (furthestAncestor(expectedNode) != expectedRoots[0]) {
expectedRoots.push(furthestAncestor(expectedNode));
}
assert_equals(actualRoots.length, expectedRoots.length,
"Either the actual node and actual range are in the same tree but the expected are in different trees, or vice versa");
assert_equals(actualRoots.length, expectedRoots.length,
"Either the actual node and actual range are in the same tree but the expected are in different trees, or vice versa");
// This doctype stuff is to work around the fact that Opera 11.00 will
// move around doctypes within a document, even to totally invalid
// positions, but it won't allow a new doctype to be added to a
// document in any way I can figure out. So if we try moving a doctype
// to some invalid place, in Opera it will actually succeed, and then
// restoreIframe() will remove the doctype along with the root element,
// and then nothing can re-add the doctype. So instead, we catch it
// during the test itself and move it back to the right place while we
// still can.
//
// I spent *way* too much time debugging and working around this bug.
var actualDoctype = actualIframe.contentDocument.doctype;
var expectedDoctype = expectedIframe.contentDocument.doctype;
// This doctype stuff is to work around the fact that Opera 11.00 will
// move around doctypes within a document, even to totally invalid
// positions, but it won't allow a new doctype to be added to a
// document in any way I can figure out. So if we try moving a doctype
// to some invalid place, in Opera it will actually succeed, and then
// restoreIframe() will remove the doctype along with the root element,
// and then nothing can re-add the doctype. So instead, we catch it
// during the test itself and move it back to the right place while we
// still can.
//
// I spent *way* too much time debugging and working around this bug.
var actualDoctype = actualIframe.contentDocument.doctype;
var expectedDoctype = expectedIframe.contentDocument.doctype;
var result;
try {
result = myInsertNode(expectedRange, expectedNode);
} catch (e) {
if (expectedDoctype != expectedIframe.contentDocument.firstChild) {
expectedIframe.contentDocument.insertBefore(expectedDoctype, expectedIframe.contentDocument.firstChild);
}
throw e;
}
if (typeof result == "string") {
assert_throws(result, function() {
try {
actualRange.insertNode(actualNode);
} catch (e) {
if (expectedDoctype != expectedIframe.contentDocument.firstChild) {
expectedIframe.contentDocument.insertBefore(expectedDoctype, expectedIframe.contentDocument.firstChild);
}
if (actualDoctype != actualIframe.contentDocument.firstChild) {
actualIframe.contentDocument.insertBefore(actualDoctype, actualIframe.contentDocument.firstChild);
}
throw e;
}
}, "A " + result + " DOMException must be thrown in this case");
// Don't return, we still need to test DOM equality
} else {
try {
actualRange.insertNode(actualNode);
} catch (e) {
if (expectedDoctype != expectedIframe.contentDocument.firstChild) {
expectedIframe.contentDocument.insertBefore(expectedDoctype, expectedIframe.contentDocument.firstChild);
}
if (actualDoctype != actualIframe.contentDocument.firstChild) {
actualIframe.contentDocument.insertBefore(actualDoctype, actualIframe.contentDocument.firstChild);
}
throw e;
}
}
var result;
try {
result = myInsertNode(expectedRange, expectedNode);
} catch (e) {
if (expectedDoctype != expectedIframe.contentDocument.firstChild) {
expectedIframe.contentDocument.insertBefore(expectedDoctype, expectedIframe.contentDocument.firstChild);
}
throw e;
}
if (typeof result == "string") {
assert_throws(result, function() {
try {
actualRange.insertNode(actualNode);
} catch (e) {
if (expectedDoctype != expectedIframe.contentDocument.firstChild) {
expectedIframe.contentDocument.insertBefore(expectedDoctype, expectedIframe.contentDocument.firstChild);
}
if (actualDoctype != actualIframe.contentDocument.firstChild) {
actualIframe.contentDocument.insertBefore(actualDoctype, actualIframe.contentDocument.firstChild);
}
throw e;
}
}, "A " + result + " DOMException must be thrown in this case");
// Don't return, we still need to test DOM equality
} else {
try {
actualRange.insertNode(actualNode);
} catch (e) {
if (expectedDoctype != expectedIframe.contentDocument.firstChild) {
expectedIframe.contentDocument.insertBefore(expectedDoctype, expectedIframe.contentDocument.firstChild);
}
if (actualDoctype != actualIframe.contentDocument.firstChild) {
actualIframe.contentDocument.insertBefore(actualDoctype, actualIframe.contentDocument.firstChild);
}
throw e;
}
}
for (var k = 0; k < actualRoots.length; k++) {
assertNodesEqual(actualRoots[k], expectedRoots[k], k ? "moved node's tree root" : "range's tree root");
}
});
domTests[i][j].done();
for (var k = 0; k < actualRoots.length; k++) {
assertNodesEqual(actualRoots[k], expectedRoots[k], k ? "moved node's tree root" : "range's tree root");
}
});
domTests[i][j].done();
positionTests[i][j].step(function() {
assert_equals(actualIframe.contentWindow.unexpectedException, null,
"Unexpected exception thrown when setting up Range for actual insertNode()");
assert_equals(expectedIframe.contentWindow.unexpectedException, null,
"Unexpected exception thrown when setting up Range for simulated insertNode()");
assert_equals(typeof actualRange, "object",
"typeof Range produced in actual iframe");
assert_false(actualRange === null,
"Range produced in actual iframe was null");
assert_equals(typeof expectedRange, "object",
"typeof Range produced in expected iframe");
assert_false(expectedRange === null,
"Range produced in expected iframe was null");
assert_equals(typeof actualNode, "object",
"typeof Node produced in actual iframe");
assert_false(actualNode === null,
"Node produced in actual iframe was null");
assert_equals(typeof expectedNode, "object",
"typeof Node produced in expected iframe");
assert_false(expectedNode === null,
"Node produced in expected iframe was null");
positionTests[i][j].step(function() {
assert_equals(actualIframe.contentWindow.unexpectedException, null,
"Unexpected exception thrown when setting up Range for actual insertNode()");
assert_equals(expectedIframe.contentWindow.unexpectedException, null,
"Unexpected exception thrown when setting up Range for simulated insertNode()");
assert_equals(typeof actualRange, "object",
"typeof Range produced in actual iframe");
assert_false(actualRange === null,
"Range produced in actual iframe was null");
assert_equals(typeof expectedRange, "object",
"typeof Range produced in expected iframe");
assert_false(expectedRange === null,
"Range produced in expected iframe was null");
assert_equals(typeof actualNode, "object",
"typeof Node produced in actual iframe");
assert_false(actualNode === null,
"Node produced in actual iframe was null");
assert_equals(typeof expectedNode, "object",
"typeof Node produced in expected iframe");
assert_false(expectedNode === null,
"Node produced in expected iframe was null");
for (var k = 0; k < actualRoots.length; k++) {
assertNodesEqual(actualRoots[k], expectedRoots[k], k ? "moved node's tree root" : "range's tree root");
}
for (var k = 0; k < actualRoots.length; k++) {
assertNodesEqual(actualRoots[k], expectedRoots[k], k ? "moved node's tree root" : "range's tree root");
}
if (detached) {
// No further tests we can do
return;
}
if (detached) {
// No further tests we can do
return;
}
assert_equals(actualRange.startOffset, expectedRange.startOffset,
"Unexpected startOffset after insertNode()");
assert_equals(actualRange.endOffset, expectedRange.endOffset,
"Unexpected endOffset after insertNode()");
// How do we decide that the two nodes are equal, since they're in
// different trees? Since the DOMs are the same, it's enough to check
// that the index in the parent is the same all the way up the tree.
// But we can first cheat by just checking they're actually equal.
assert_true(actualRange.startContainer.isEqualNode(expectedRange.startContainer),
"Unexpected startContainer after insertNode(), expected " +
expectedRange.startContainer.nodeName.toLowerCase() + " but got " +
actualRange.startContainer.nodeName.toLowerCase());
var currentActual = actualRange.startContainer;
var currentExpected = expectedRange.startContainer;
var actual = "";
var expected = "";
while (currentActual && currentExpected) {
actual = indexOf(currentActual) + "-" + actual;
expected = indexOf(currentExpected) + "-" + expected;
assert_equals(actualRange.startOffset, expectedRange.startOffset,
"Unexpected startOffset after insertNode()");
assert_equals(actualRange.endOffset, expectedRange.endOffset,
"Unexpected endOffset after insertNode()");
// How do we decide that the two nodes are equal, since they're in
// different trees? Since the DOMs are the same, it's enough to check
// that the index in the parent is the same all the way up the tree.
// But we can first cheat by just checking they're actually equal.
assert_true(actualRange.startContainer.isEqualNode(expectedRange.startContainer),
"Unexpected startContainer after insertNode(), expected " +
expectedRange.startContainer.nodeName.toLowerCase() + " but got " +
actualRange.startContainer.nodeName.toLowerCase());
var currentActual = actualRange.startContainer;
var currentExpected = expectedRange.startContainer;
var actual = "";
var expected = "";
while (currentActual && currentExpected) {
actual = indexOf(currentActual) + "-" + actual;
expected = indexOf(currentExpected) + "-" + expected;
currentActual = currentActual.parentNode;
currentExpected = currentExpected.parentNode;
}
actual = actual.substr(0, actual.length - 1);
expected = expected.substr(0, expected.length - 1);
assert_equals(actual, expected,
"startContainer superficially looks right but is actually the wrong node if you trace back its index in all its ancestors (I'm surprised this actually happened");
});
positionTests[i][j].done();
currentActual = currentActual.parentNode;
currentExpected = currentExpected.parentNode;
}
actual = actual.substr(0, actual.length - 1);
expected = expected.substr(0, expected.length - 1);
assert_equals(actual, expected,
"startContainer superficially looks right but is actually the wrong node if you trace back its index in all its ancestors (I'm surprised this actually happened");
});
positionTests[i][j].done();
}
testRanges.unshift('"detached"');
@ -242,22 +242,22 @@ var jStart = 0;
var jStop = testNodesShort.length;
if (/subtest=[0-9]+,[0-9]+/.test(location.search)) {
var matches = /subtest=([0-9]+),([0-9]+)/.exec(location.search);
iStart = Number(matches[1]);
iStop = Number(matches[1]) + 1;
jStart = Number(matches[2]) + 0;
jStop = Number(matches[2]) + 1;
var matches = /subtest=([0-9]+),([0-9]+)/.exec(location.search);
iStart = Number(matches[1]);
iStop = Number(matches[1]) + 1;
jStart = Number(matches[2]) + 0;
jStop = Number(matches[2]) + 1;
}
var domTests = [];
var positionTests = [];
for (var i = iStart; i < iStop; i++) {
domTests[i] = [];
positionTests[i] = [];
for (var j = jStart; j < jStop; j++) {
domTests[i][j] = async_test(i + "," + j + ": resulting DOM for range " + testRangesShort[i] + ", node " + testNodesShort[j]);
positionTests[i][j] = async_test(i + "," + j + ": resulting range position for range " + testRangesShort[i] + ", node " + testNodesShort[j]);
}
domTests[i] = [];
positionTests[i] = [];
for (var j = jStart; j < jStop; j++) {
domTests[i][j] = async_test(i + "," + j + ": resulting DOM for range " + testRangesShort[i] + ", node " + testNodesShort[j]);
positionTests[i][j] = async_test(i + "," + j + ": resulting range position for range " + testRangesShort[i] + ", node " + testNodesShort[j]);
}
}
var actualIframe = document.createElement("iframe");
@ -272,15 +272,15 @@ var referenceDoc = document.implementation.createHTMLDocument("");
referenceDoc.removeChild(referenceDoc.documentElement);
actualIframe.onload = function() {
expectedIframe.onload = function() {
for (var i = iStart; i < iStop; i++) {
for (var j = jStart; j < jStop; j++) {
testInsertNode(i, j);
}
}
}
expectedIframe.src = "Range-test-iframe.html";
referenceDoc.appendChild(actualIframe.contentDocument.documentElement.cloneNode(true));
expectedIframe.onload = function() {
for (var i = iStart; i < iStop; i++) {
for (var j = jStart; j < jStop; j++) {
testInsertNode(i, j);
}
}
}
expectedIframe.src = "Range-test-iframe.html";
referenceDoc.appendChild(actualIframe.contentDocument.documentElement.cloneNode(true));
}
actualIframe.src = "Range-test-iframe.html";
</script>

View File

@ -0,0 +1,39 @@
<!doctype html>
<title>DOMParser basic test of HTML parsing</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
// |expected| should be an object indicating the expected type of node.
function assert_node(actual, expected) {
assert_true(actual instanceof expected.type,
'Node type mismatch: actual = ' + actual.nodeType + ', expected = ' + expected.nodeType);
if (typeof(expected.id) !== 'undefined')
assert_equals(actual.id, expected.id, expected.idMessage);
if (typeof(expected.nodeValue) !== 'undefined')
assert_equals(actual.nodeValue, expected.nodeValue, expected.nodeValueMessage);
}
var doc;
setup(function() {
var parser = new DOMParser();
var input = '<html id="root"><head></head><body></body></html>';
doc = parser.parseFromString(input, 'text/html');
});
test(function() {
var root = doc.documentElement;
assert_node(root, { type: HTMLHtmlElement, id: 'root',
idMessage: 'documentElement id attribute should be root.' });
}, 'Parsing of id attribute');
test(function() {
assert_equals(document.documentURI, doc.documentURI,
'The document must have a URL value equal to the URL of the active document.');
}, 'URL value');
test(function() {
assert_equals(doc.location, null,
'The document must have a location value of null.');
}, 'Location value');
</script>

View File

@ -1,4 +1,5 @@
<!doctype html>
<meta name=timeout content=long>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
@ -6,52 +7,68 @@
// https://encoding.spec.whatwg.org/encodings.json
var singleByteEncodings = [{
"labels": [ "866", "cp866", "csibm866", "ibm866" ],
"name": "ibm866"
"name": "ibm866",
"cName": "IBM866"
},{
"labels": [ "csisolatin2", "iso-8859-2", "iso-ir-101", "iso8859-2", "iso88592", "iso_8859-2", "iso_8859-2:1987", "l2", "latin2" ],
"name": "iso-8859-2"
"name": "iso-8859-2",
"cName": "ISO-8859-2"
},{
"labels": [ "csisolatin3", "iso-8859-3", "iso-ir-109", "iso8859-3", "iso88593", "iso_8859-3", "iso_8859-3:1988", "l3", "latin3" ],
"name": "iso-8859-3"
"name": "iso-8859-3",
"cName": "ISO-8859-3"
},{
"labels": [ "csisolatin4", "iso-8859-4", "iso-ir-110", "iso8859-4", "iso88594", "iso_8859-4", "iso_8859-4:1988", "l4", "latin4" ],
"name": "iso-8859-4"
"name": "iso-8859-4",
"cName": "ISO-8859-4"
},{
"labels": [ "csisolatincyrillic", "cyrillic", "iso-8859-5", "iso-ir-144", "iso8859-5", "iso88595", "iso_8859-5", "iso_8859-5:1988" ],
"name": "iso-8859-5"
"name": "iso-8859-5",
"cName": "ISO-8859-5"
},{
"labels": [ "arabic", "asmo-708", "csiso88596e", "csiso88596i", "csisolatinarabic", "ecma-114", "iso-8859-6", "iso-8859-6-e", "iso-8859-6-i", "iso-ir-127", "iso8859-6", "iso88596", "iso_8859-6", "iso_8859-6:1987" ],
"name": "iso-8859-6"
"name": "iso-8859-6",
"cName": "ISO-8859-6"
},{
"labels": [ "csisolatingreek", "ecma-118", "elot_928", "greek", "greek8", "iso-8859-7", "iso-ir-126", "iso8859-7", "iso88597", "iso_8859-7", "iso_8859-7:1987", "sun_eu_greek" ],
"name": "iso-8859-7"
"name": "iso-8859-7",
"cName": "ISO-8859-7"
},{
"labels": [ "csiso88598e", "csisolatinhebrew", "hebrew", "iso-8859-8", "iso-8859-8-e", "iso-ir-138", "iso8859-8", "iso88598", "iso_8859-8", "iso_8859-8:1988", "visual" ],
"name": "iso-8859-8"
"name": "iso-8859-8",
"cName": "ISO-8859-8"
},{
"labels": [ "csiso88598i", "iso-8859-8-i", "logical" ],
"name": "iso-8859-8-i"
"name": "iso-8859-8-i",
"cName": "ISO-8859-8-I"
},{
"labels": [ "csisolatin6", "iso-8859-10", "iso-ir-157", "iso8859-10", "iso885910", "l6", "latin6" ],
"name": "iso-8859-10"
"name": "iso-8859-10",
"cName": "ISO-8859-10"
},{
"labels": [ "iso-8859-13", "iso8859-13", "iso885913" ],
"name": "iso-8859-13"
"name": "iso-8859-13",
"cName": "ISO-8859-13"
},{
"labels": [ "iso-8859-14", "iso8859-14", "iso885914" ],
"name": "iso-8859-14"
"name": "iso-8859-14",
"cName": "ISO-8859-14"
},{
"labels": [ "csisolatin9", "iso-8859-15", "iso8859-15", "iso885915", "iso_8859-15", "l9" ],
"name": "iso-8859-15"
"name": "iso-8859-15",
"cName": "ISO-8859-15"
},{
"labels": [ "iso-8859-16" ],
"name": "iso-8859-16"
"name": "iso-8859-16",
"cName": "ISO-8859-16"
},{
"labels": [ "cskoi8r", "koi", "koi8", "koi8-r", "koi8_r" ],
"name": "koi8-r"
"name": "koi8-r",
"cName": "KOI8-R"
},{
"labels": [ "koi8-u" ],
"name": "koi8-u"
"name": "koi8-u",
"cName": "KOI8-U"
},{
"labels": [ "csmacintosh", "mac", "macintosh", "x-mac-roman" ],
"name": "macintosh"
@ -121,8 +138,8 @@
}
// For TextDecoder tests
var buffer = ArrayBuffer(255),
view = Uint8Array(buffer)
var buffer = new ArrayBuffer(255),
view = new Uint8Array(buffer)
for(var i = 0, l = view.byteLength; i < l; i++) {
view[i] = i
}
@ -165,12 +182,15 @@
async_test(function(t) {
var frame = document.createElement("iframe"),
name = encoding.name
name = encoding.cName || encoding.name
frame.src = "resources/single-byte-raw.py?label=" + label
frame.onload = t.step_func_done(function() { assert_equals(frame.contentDocument.characterSet, name) })
frame.onload = t.step_func_done(function() {
assert_equals(frame.contentDocument.characterSet, name)
assert_equals(frame.contentDocument.inputEncoding, name)
})
t.add_cleanup(function() { document.body.removeChild(frame) })
document.body.appendChild(frame)
}, encoding.name + ": " + label + " (document.characterSet)")
}, encoding.name + ": " + label + " (document.characterSet and document.inputEncoding)")
}
}
</script>

View File

@ -0,0 +1,34 @@
<!doctype html>
<html>
<head>
<title>Manual Gamepad events tests</title>
<link rel="help" href="https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#the-gamepadconnected-event">
<link rel="help" href="https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#the-gamepaddisconnected-event">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({explicit_timeout: true});
function set_instructions(text) {
document.getElementById("instructions").textContent = text;
}
var index = -1;
addEventListener("gamepadconnected", function (e) {
assert_equals(index, -1, "Too many connected events?");
assert_class_string(e, "GamepadEvent");
assert_class_string(e.gamepad, "Gamepad");
index = e.gamepad.index;
set_instructions("Found a gamepad. Now disconnect the gamepad.");
});
addEventListener("gamepaddisconnected", function (e) {
assert_class_string(e, "GamepadEvent");
assert_equals(e.gamepad.index, index);
done();
});
</script>
</head>
<body>
<p id="instructions">This test requires a gamepad. Connect one and press any button to start the test.</p>
</body>
</html>

View File

@ -0,0 +1,30 @@
<!doctype html>
<html>
<head>
<title>Manual Gamepad getGamepads polling tests</title>
<link rel="help" href="https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({explicit_timeout: true});
// Poll until we see a gamepad.
var id = setInterval(function() {
var gamepads = navigator.getGamepads();
var found = null;
for (var i = 0; i < gamepads.length; i++) {
if (gamepads[i]) {
found = gamepads[i];
break;
}
}
if (found) {
clearInterval(id);
done();
}
}, 15);
</script>
</head>
<body>
<p>This test requires a gamepad. Connect one and press any button to start the test.</p>
</body>
</html>

View File

@ -0,0 +1,78 @@
<!doctype html>
<html>
<head>
<title>Manual Gamepad IDL tests</title>
<link rel="help" href="https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#gamepad-interface">
<link rel="help" href="https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#gamepadbutton-interface">
<link rel="help" href="https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#gamepadevent-interface">
<link rel="help" href="https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
<script>
setup({explicit_done: true, explicit_timeout: true});
addEventListener("gamepadconnected", function (e) {
var idl_array = new IdlArray();
idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
idl_array.add_idls(document.getElementById("idl").textContent);
idl_array.add_objects({
GamepadEvent: [e],
Gamepad: [e.gamepad],
GamepadButton: [e.gamepad.buttons[0]],
Navigator: ["navigator"],
});
idl_array.test();
done();
});
</script>
</head>
<body>
<pre id="untested_idl" style="display: none">
interface Navigator {
};
interface Event {
};
</pre>
<pre id="idl" style="display: none">
interface Gamepad {
readonly attribute DOMString id;
readonly attribute long index;
readonly attribute boolean connected;
readonly attribute DOMHighResTimeStamp timestamp;
readonly attribute GamepadMappingType mapping;
readonly attribute double[] axes;
readonly attribute GamepadButton[] buttons;
};
enum GamepadMappingType {
"",
"standard"
};
interface GamepadButton {
readonly attribute boolean pressed;
readonly attribute double value;
};
[Constructor(DOMString type, optional GamepadEventInit eventInitDict)]
interface GamepadEvent : Event
{
readonly attribute Gamepad? gamepad;
};
dictionary GamepadEventInit : EventInit
{
Gamepad? gamepad = null;
};
partial interface Navigator {
Gamepad[] getGamepads();
};
</pre>
<p id="instructions">This test requires a gamepad. Connect one and press any button to start the test.</p>
<div id="log"></div>
</body>
</html>

View File

@ -0,0 +1,70 @@
<!doctype html>
<html>
<head>
<title>Gamepad IDL tests</title>
<link rel="help" href="https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#gamepad-interface">
<link rel="help" href="https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#gamepadbutton-interface">
<link rel="help" href="https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#gamepadevent-interface">
<link rel="help" href="https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
</head>
<body>
<pre id="untested_idl" style="display: none">
interface Navigator {
};
interface Event {
};
</pre>
<pre id="idl" style="display: none">
interface Gamepad {
readonly attribute DOMString id;
readonly attribute long index;
readonly attribute boolean connected;
readonly attribute DOMHighResTimeStamp timestamp;
readonly attribute GamepadMappingType mapping;
readonly attribute double[] axes;
readonly attribute GamepadButton[] buttons;
};
enum GamepadMappingType {
"",
"standard"
};
interface GamepadButton {
readonly attribute boolean pressed;
readonly attribute double value;
};
[Constructor(DOMString type, optional GamepadEventInit eventInitDict)]
interface GamepadEvent : Event
{
readonly attribute Gamepad? gamepad;
};
dictionary GamepadEventInit : EventInit
{
Gamepad? gamepad = null;
};
partial interface Navigator {
Gamepad[] getGamepads();
};
</pre>
<script>
var idl_array = new IdlArray();
idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
idl_array.add_idls(document.getElementById("idl").textContent);
idl_array.add_objects({
GamepadEvent: [new GamepadEvent("something")],
Navigator: ["navigator"],
});
idl_array.test();
</script>
<div id="log"></div>
</body>
</html>

View File

@ -0,0 +1,58 @@
<!doctype html>
<html>
<head>
<title>Manual Gamepad timestamp tests</title>
<link rel="help" href="https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#widl-Gamepad-timestamp">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({explicit_timeout: true});
function set_instructions(text) {
document.getElementById("instructions").textContent = text;
}
var index = -1;
var lastTimestamp = performance.now();
var id = -1;
addEventListener("gamepadconnected", function (e) {
assert_equals(index, -1, "Too many connected events?");
index = e.gamepad.index;
assert_greater_than(e.gamepad.timestamp, lastTimestamp, "timestamp should be increasing");
lastTimestamp = e.gamepad.timestamp;
set_instructions("Found a gamepad. Now release the button you pressed and press it again.");
// There may not be a button pressed here, so handle it cleanly either way.
if (e.gamepad.buttons.some(function (b) { return b.pressed; })) {
id = setInterval(waitForButtonRelease, 15);
} else {
id = setInterval(waitForButtonPress, 15);
}
});
function waitForButtonRelease() {
var gamepad = navigator.getGamepads()[index];
assert_true(!!gamepad);
if (gamepad.buttons.every(function (b) { return !b.pressed; })) {
assert_greater_than(gamepad.timestamp, lastTimestamp, "timestamp should be increasing");
lastTimestamp = gamepad.timestamp;
clearInterval(id);
id = setInterval(waitForButtonPress, 15);
}
}
function waitForButtonPress() {
var gamepad = navigator.getGamepads()[index];
assert_true(!!gamepad);
if (gamepad.buttons.some(function (b) { return b.pressed; })) {
assert_greater_than(gamepad.timestamp, lastTimestamp, "timestamp should be increasing");
clearInterval(id);
done();
}
}
</script>
</head>
<body>
<p id="instructions">This test requires a gamepad. Connect one and press any button to start the test.</p>
</body>
</html>

View File

@ -34,8 +34,8 @@ var miscElements = {
summary: {},
menu: {
// Conforming
//TODO: type has complicated missing value default behaviour
//type: {type: "enum", keywords:["popup", "toolbar"]},
//TODO: check that missing value default is popup if parent's type is popup
type: {type: "enum", keywords:["popup", "toolbar"], defaultVal: "toolbar"},
label: "string",
// Obsolete

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<title>Element Custom Attributes</title>
<link rel="author" title="Bruno de Oliveira Abinader" href="mailto:bruno.d@partner.samsung.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/dom.html#dom-dataset">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#xml">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/dom/nodes/attributes.js"></script>
</head>
<body>
<h1>Element Custom Attributes</h1>
<div id="log"></div>
<script>
test(function() {
var div = document.createElement("div");
div.setAttributeNS("foo", "data-my-custom-attr", "first");
div.setAttributeNS("bar", "data-my-custom-attr", "second");
div.dataset.myCustomAttr = "third";
assert_equals(div.attributes.length, 3);
attributes_are(div, [["data-my-custom-attr", "first", "foo"],
["data-my-custom-attr", "second", "bar"],
["data-my-custom-attr", "third", null]]);
}, "Setting an Element's dataset property should not interfere with namespaced attributes with same name");
</script>
</body>
</html>

View File

@ -47,12 +47,6 @@ exception DOMException {
unsigned short code;
};
[Constructor(DOMString name, optional DOMString message = "")]
interface DOMError {
readonly attribute DOMString name;
readonly attribute DOMString message;
};
[Constructor(DOMString type, optional EventInit eventInitDict),
Exposed=Window,Worker]
interface Event {
@ -266,6 +260,7 @@ interface Document : Node {
readonly attribute DOMString origin;
readonly attribute DOMString compatMode;
readonly attribute DOMString characterSet;
readonly attribute DOMString inputEncoding; // legacy alias of .characterSet
readonly attribute DOMString contentType;
readonly attribute DocumentType? doctype;

View File

@ -1,5 +1,5 @@
def main(request, response):
encoding = request.GET['encoding']
tmpl = request.GET['tmpl']
sheet = tmpl % u'\u00E5'
sheet = tmpl % u'\\0000E5'
return [("Content-Type", "text/css; charset=%s" % encoding)], sheet.encode(encoding)

View File

@ -100,7 +100,7 @@ def main(request, response):
return [("Content-Type", "image/svg+xml")], "<svg xmlns='http://www.w3.org/2000/svg'>%s</svg>" % q
elif type == 'xmlstylesheet_css':
return ([("Content-Type", "application/xhtml+xml; charset=%s" % encoding)],
(u"""<?xml-stylesheet href="?q=\u00E5&amp;type=css&amp;encoding=%s"?><html xmlns="http://www.w3.org/1999/xhtml"/>""" % encoding)
(u"""<?xml-stylesheet href="?q=&#x00E5;&amp;type=css&amp;encoding=%s"?><html xmlns="http://www.w3.org/1999/xhtml"/>""" % encoding)
.encode(encoding))
elif type == 'png':
if q == '%E5':

View File

@ -0,0 +1,19 @@
<!doctype html>
<title>Option labels</title>
<select size=12>
<option><!-- No children, no label-->
<option><!-- No children, empty label-->
<option>label<!-- No children, label-->
<option><!-- No children, namespaced label-->
<option>child<!-- Single child, no label-->
<option>child<!-- Single child, empty label-->
<option>label<!-- Single child, label-->
<option>child<!-- Single child, namespaced label-->
<option>child node<!-- Two children, no label-->
<option>child node<!-- Two children, empty label-->
<option>label<!-- Two children, label-->
<option>child node<!-- Two children, namespaced label-->
</select>

View File

@ -0,0 +1,65 @@
<!doctype html>
<title>Option labels</title>
<select size=12></select>
<script>
var select = document.getElementsByTagName("select")[0], option;
option = document.createElement("option");
select.appendChild(option);
option = document.createElement("option");
option.setAttribute("label", "")
select.appendChild(option);
option = document.createElement("option");
option.setAttribute("label", "label")
select.appendChild(option);
option = document.createElement("option");
option.setAttributeNS("http://www.example.com/", "label", "label")
select.appendChild(option);
option = document.createElement("option");
option.appendChild(document.createTextNode(" child "));
select.appendChild(option);
option = document.createElement("option");
option.appendChild(document.createTextNode(" child "));
option.setAttribute("label", "")
select.appendChild(option);
option = document.createElement("option");
option.appendChild(document.createTextNode(" child "));
option.setAttribute("label", "label")
select.appendChild(option);
option = document.createElement("option");
option.appendChild(document.createTextNode(" child "));
option.setAttributeNS("http://www.example.com/", "label", "label")
select.appendChild(option);
option = document.createElement("option");
option.appendChild(document.createTextNode(" child "));
option.appendChild(document.createTextNode(" node "));
select.appendChild(option);
option = document.createElement("option");
option.appendChild(document.createTextNode(" child "));
option.appendChild(document.createTextNode(" node "));
option.setAttribute("label", "")
select.appendChild(option);
option = document.createElement("option");
option.appendChild(document.createTextNode(" child "));
option.appendChild(document.createTextNode(" node "));
option.setAttribute("label", "label")
select.appendChild(option);
option = document.createElement("option");
option.appendChild(document.createTextNode(" child "));
option.appendChild(document.createTextNode(" node "));
option.setAttributeNS("http://www.example.com/", "label", "label")
select.appendChild(option);
</script>

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>[body - TEXT=00ffff] Reference file</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<style>
body {
color: blue;
}
</style>
<body>
<p>This document should have text color 'Blue' using the RGB Hexadecimal color value of "0000ff". </p>
<p>This test passes if the color of text above matches the image below.</p>
<p><img src="/images/blue.png"/></p>
</body>

View File

@ -1,13 +1,12 @@
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>body - TEXT=00ffff</title>
<link rel="match" href="body_text_00ffff-ref.html"/>
<meta name="assert" content="Test checks that User Agent requirement as per HTML5 spec NOT the author requirement."/>
</head>
<body text="0000ff">
<p>This document should have text color 'Blue' using the RGB Hexadecimal color value of "0000ff". </p>
<p>This test passes if the color of text above matches the image below.</p>
<p><img src="../../../../../images/blue.png" /></p>
<p><img src="/images/blue.png" /></p>
</body>
<p>
<i>Note - This test checks for User Agent requirement as per HTML5 spec NOT the author requirement. (This text is not inside body, so text color is default - black)</i>
</p>
</html>

View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>[style] Reference file</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<style>
h4 {
color: green;
}
</style>
<body>
<p>
This page tests that Style written inside HTML comment is not applied
</p>
This test passes if the text below is <b>Green. NOT Red.</b>
<h4>
This is some text.
</h4>
</body>

View File

@ -1,5 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="match" href="html_style_in_comment-ref.html"/>
<style type="text/css">
h4 {color: green}
<!--
@ -14,4 +15,4 @@ This test passes if the text below is <b>Green. NOT Red.</b>
This is some text.
</h4>
</body>
</html>
</html>

View File

@ -22,7 +22,6 @@ def main(request, response):
return "OK"
elif "delete-cookie" in request.GET:
print "delete-cookie"
response.delete_cookie(id)
return [("Content-Type", "text/plain")], "OK"

View File

@ -9,8 +9,8 @@
<meta name="assert" content="Content inside the 'audio' element is not shown to the user (image)." />
</head>
<body>
<p>Test passes if there is no red.</p>
<div id='testcontent'>
<audio><img src="../../../../images/fail.gif" /></audio>
</div>

View File

@ -9,8 +9,8 @@
<meta name="assert" content="Content inside the 'audio' element is not shown to the user." />
</head>
<body>
<p>Test passes if there is no red.</p>
<div id='testcontent'>
<audio><span style="color: red;">FAIL</span></audio>
</div>

View File

@ -6,8 +6,8 @@
<link rel="author" title="Microsoft" href="http://www.microsoft.com/" />
</head>
<body>
<p>Test passes if there is no red.</p>
<div id='testcontent'>
</div>
</body>
</html>

View File

@ -18,8 +18,8 @@
setup({explicit_done:true});
onload = function() {
[].forEach.call(document.images, function(img) {
var expected = parseFloat(img.dataset.expect);
test(function() {
var expected = parseFloat(img.dataset.expect);
assert_equals(img.width, expected, 'width');
assert_equals(img.height, expected, 'height');
assert_equals(img.clientWidth, expected, 'clientWidth');

View File

@ -14,7 +14,6 @@
var obj1;
var obj2;
var t1 = async_test("object.contentWindow");
var t2 = async_test("object.form");
var t3 = async_test("object.width");
var t4 = async_test("object.height");
@ -36,11 +35,6 @@
});
t1.done()
t2.step(function() {
assert_equals(obj1.form, document.forms[0], "Missing form attribute returns the nearest ancestor form element.");
});
t2.done();
t3.step(function() {
assert_equals(getComputedStyle(obj1, null)["width"], "100px", "The width should be 100px.");
});

View File

@ -0,0 +1,46 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTMLInputElement#form</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>
<form id="form">
<p><button id="button">button</button>
<p><fieldset id="fieldset">fieldset</fieldset>
<p><input id="input">
<p><keygen id="keygen">
<p><label id="label">label</label>
<p><object id="object">object</object>
<p><output id="output">output</output>
<p><select id="select"><option>select</option></select>
<p><textarea id="textarea">textarea</textarea>
</form>
<script>
var form;
setup(function() {
form = document.getElementById("form");
if (!form) {
throw new TypeError("Didn't find form");
}
});
var reassociateableElements = [
"button",
"fieldset",
"input",
"keygen",
"label",
"object",
"output",
"select",
"textarea",
];
reassociateableElements.forEach(function(localName) {
test(function() {
var button = document.getElementById(localName);
assert_equals(button.form, form);
}, localName + ".form");
});
</script>

View File

@ -1,7 +1,8 @@
<!doctype html>
<title>WeakMap.prototype</title>
<link rel=author href=mailto:Ms2ger@gmail.com title=Ms2ger>
<link rel=help href=http://people.mozilla.org/~jorendorff/es6-draft.html#sec-15.15.5>
<link rel=help href=https://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-weakmap-prototype-object>
<link rel=help href=https://people.mozilla.org/~jorendorff/es6-draft.html#sec-functioninitialize>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
@ -16,7 +17,7 @@ function assert_propdesc(obj, prop, Writable, Enumerable, Configurable) {
function test_length(fun, expected) {
test(function() {
assert_propdesc(WeakMap.prototype[fun], "length", false, false, false);
assert_propdesc(WeakMap.prototype[fun], "length", false, false, true);
assert_equals(WeakMap.prototype[fun].length, expected);
}, "WeakMap.prototype." + fun + ".length")
}

View File

@ -0,0 +1,4 @@
WEBVTT
00:00:00.000 --> 00:00:05.000
Foo

View File

@ -0,0 +1 @@
Access-Control-Allow-Origin: *

View File

@ -1,42 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Forms</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<p>
<h3>button_form</h3>
</p>
<hr>
<div id="log"></div>
<form method="post"
enctype="application/x-www-form-urlencoded"
action=""
name="input_form">
<p><button id='button_id'>button</button></p>
</form>
<script>
var button = document.getElementById("button_id");
var form = button.form;
if (typeof(form) == "object") {
test(function() {
assert_equals(form.name, 'input_form', "form attribute is not correct.");
});
} else {
test(function() {
assert_unreached("form attribute is not exist.");
});
}
</script>
</body>
</html>

View File

@ -1,46 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Forms</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<p>
<h3>datalist_options</h3>
</p>
<hr>
<div id="log"></div>
<form method="post"
enctype="application/x-www-form-urlencoded"
action=""
name="input_form">
<p><input type='text' id='input_url' list="urls"></p>
<datalist id="urls">
<option value="http://www.google.com/" label="Google">
<option value="http://www.reddit.com/" label="Reddit">
</datalist>
</form>
<script>
var datalist = document.getElementById("urls");
var options = datalist.options;
if (typeof(options) == "object") {
test(function() {
assert_equals(options.length, 2, "list attribute is not correct.");
});
} else {
test(function() {
assert_unreached("list attribute is not exist.");
});
}
</script>
</body>
</html>

View File

@ -1,42 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Forms</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<p>
<h3>FieldSet_form</h3>
</p>
<hr>
<div id="log"></div>
<form method="post"
enctype="application/x-www-form-urlencoded"
action=""
name="input_form"
id="input_form">
<fieldset id="input_field">
</fieldset>
</form>
<script>
var field = document.getElementById("input_field");
if (typeof(field.form) == "object") {
test(function() {
assert_equals(field.form.name, "input_form", "form attribute is not correct.");
});
} else {
test(function() {
assert_unreached("form attribute is not exist.");
});
}
</script>
</body>
</html>

View File

@ -1,50 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Forms</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<p>
<h3>Form_getterindex[]</h3>
</p>
<hr>
<div id="log"></div>
<form method="post"
enctype="application/x-www-form-urlencoded"
action=""
id="input_form">
<p><input type=hidden name="custname"></p>
<p><input type=hidden name="custtel"></p>
<p><input type=hidden name="custemail"></p>
</form>
<script>
var form = document.getElementById("input_form");
var ele;
try
{
ele = form[1];
test(function() {
assert_equals(ele.name, "custtel", "getter[index] attribute is not correct.");
});
}
catch (e)
{
test(function() {
assert_unreached("getter[index] is not supported.");
});
}
</script>
</body>
</html>

View File

@ -1,42 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Forms</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<p>
<h3>input_form</h3>
</p>
<hr>
<div id="log"></div>
<form method="post"
enctype="application/x-www-form-urlencoded"
action=""
name="input_form">
<p><input type='hidden' id='input_text'></p>
</form>
<script>
var input_text = document.getElementById("input_text");
var form = input_text.form;
if (typeof(form) == "object") {
test(function() {
assert_equals(form.name, 'input_form', "form attribute is not correct.");
});
} else {
test(function() {
assert_unreached("form attribute is not exist.");
});
}
</script>
</body>
</html>

View File

@ -1,39 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Forms</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<p>
<h3>keygen_form</h3>
</p>
<hr>
<div id="log"></div>
<form onsubmit="return false" name='input_form'>
<p><keygen name="key" id='keygen_id'></keygen></p>
</form>
<script>
var keygen = document.getElementById("keygen_id");
var form = keygen.form;
if (typeof(form) == "object") {
test(function() {
assert_equals(form.name, "input_form", "form attribute is not correct.");
});
} else {
test(function() {
assert_unreached("form attribute is not exist.");
});
}
</script>
</body>
</html>

View File

@ -39,9 +39,12 @@
on_event(target0, "pointerout", function (event) {
pointeroutCounter++;
test(function() {
assert_true(pointeroutCounter == 1, "pointerout received just once")
}, "pointerout received just once");
setTimeout(function() {
test(function() {
assert_true(pointeroutCounter == 1, "pointerout received just once")
}, "pointerout received just once");
done();
}, 5000);
});
}
</script>

View File

@ -23,7 +23,7 @@
function eventHandler(event) {
detected_pointertypes[event.pointerType] = true;
if(!eventTested) {
if(!eventTested && event.type == "pointerover") {
check_PointerEvent(event);
test_pointerEvent.step(function () {
assert_equals(event.pointerType, "mouse", "Verify event.pointerType is 'mouse'.");

View File

@ -24,6 +24,7 @@
var f_lostPointerCapture = false;
function listenerEventHandler(event) {
detected_pointertypes[event.pointerType] = true;
if (event.type == "gotpointercapture") {
f_gotPointerCapture = true;
check_PointerEvent(event);
@ -91,18 +92,6 @@
on_event(listener, All_Pointer_Events[i], listenerEventHandler);
}
}
function showPointerTypes() {
var complete_notice = document.getElementById("complete-notice");
var pointertype_log = document.getElementById("pointertype-log");
var pointertypes = Object.keys(detected_pointertypes); pointertype_log.innerHTML = pointertypes.length ? pointertypes.join(",") : "(none)";
if (test_pointerEvent.status == test_pointerEvent.NOTRUN
|| test_pointerEvent.status == test_pointerEvent.TIMEOUT) {
complete_notice.innerHTML = "Test FAIL due to time out. This is due to the browser not supporting pointer, or the manual steps were not run to completion.";
complete_notice.style.background = "red";
}
complete_notice.style.display = "block";
}
</script>
</head>
<body onload="run()">

View File

@ -8,13 +8,11 @@
<script src="/resources/testharnessreport.js"></script>
<script src="pointerevent_support.js"></script>
<script type="text/javascript">
var detected_pointertypes = {};
add_completion_callback(showPointerTypes);
var test_setPointerCapture = async_test("setPointerCapture: DOMException InvalidStateError");
function run() {
var detected_pointertypes = {};
add_completion_callback(showPointerTypes);
var target0 = document.getElementById("target0");
var target1 = document.getElementById("target1");

View File

@ -1,48 +0,0 @@
<!doctype html>
<html>
<head>
<title>ProgressEvent: security consideration</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="http://dvcs.w3.org/hg/progress/raw-file/tip/Overview.html#security-considerations" data-tested-assertations="/following-sibling::p" />
</head>
<body>
<div id="log"></div>
<script>
var test = async_test();
test.step(function() {
var xhr = new XMLHttpRequest();
xhr.onprogress = function(pe) {
test.step(function() {
if(pe.type == "progress") {
assert_unreached("MUST NOT dispatch progress event.");
}
}, "Progress event named progress is not dispatched.");
}
xhr.onload = function(pe) {
test.step(function() {
if(pe.type == "load") {
assert_unreached("MUST NOT dispatch progress event.");
}
}, "Progress event named load is not dispatched.");
}
xhr.onerror = function(pe) {
test.step(function() {
if(pe.type == "error") {
assert_equals(pe.loaded, 0, "loaded is zero.");
assert_false(pe.lengthComputable, "lengthComputable is false.");
assert_equals(pe.total, 0, "total is zero.");
}
}, "Progress event named error does not reveal information.");
}
xhr.onloadend = function(pe) {
test.done();
}
xhr.open("GET", "http://{{host}}:{{ports[http][1]}}/progress-events/tests/submissions/Samsung/resources/img.jpg", true);
xhr.send(null);
})
</script>
</body>
</html>

View File

@ -0,0 +1,176 @@
<!doctype html>
<html>
<head>
<title>The :active and :hover quirk</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style> iframe { width:100%; height:200px; } </style>
</head>
<body>
<p>Click on the boxes below (using a pointing device). <button onclick="timeout()">Abort and show results</button></p>
<div id=log></div>
<p>quirks:
<iframe id=quirks></iframe>
<p>almost:
<iframe id=almost></iframe>
<p>standards:
<iframe id=standards></iframe>
<script type="text/plain" id=html_tmpl>
<html id=html class=x lang=en>
<style>
.t:not(area), img { display:inline-block; vertical-align:middle; width:50px; height:50px; background-color:#eee; margin:0 0.5em }
.done.done { background-color:lime }
link::before { content:'' }
table, tbody, tr, td { display:inline }
</style>
<style>{style}</style>
<body id=body class=x>
a<a href=# id=a class=t></a>
b<a id=b class=t></a>
c<map id=map1 name=map1 class=x><area href=# coords=0,0,50,50 id=c class=t></map><img id=img1 class=x usemap=#map1 src=/images/transparent.png>
d<map id=map2 name=map2 class=x><area coords=0,0,50,50 id=d class=t></map><img id=img2 class=x usemap=#map2 src=/images/transparent.png>
e<link href=# id=e class=t>
f<link rel=stylesheet href=# id=f class=t>
g<link id=g class=t>
h<button id=h class=t></button>
i<input type=submit id=i class=t value>
j<input type=image id=j class=t alt>
k<input type=reset id=k class=t value>
l<input type=button id=l class=t value>
m<menuitem id=m class=t></menuitem>
n<img tabindex=0 id=n class=t src=/images/transparent.png>
o<a href=# id=a_ancestor class=x><table id=table class=x><tbody id=tbody class=x><tr id=tr class=x><td id=td class=x><a href=# id=o class=t></a></table></a>
</script>
<script>
setup({explicit_done:true, explicit_timeout:true});
onload = function() {
var links_only = [
{input:':active', prop:'background-attachment', value:'fixed'},
{input:':hover', prop:'background-position', value:'1px 2px'},
{input:':hover:active', prop:'background-repeat', value:'repeat-x'},
{input:':active:active', prop:'border-collapse', value:'collapse'},
{input:':hover:hover', prop:'border-spacing', value:'1px 2px'},
{input:'*:active', prop:'border-top-style', value:'dotted'},
{input:'*:hover', prop:'border-right-style', value:'dotted'},
];
var any_elm = [
// type selector
{input:'a:active, map:active, area:active, link:active, button:active, input:active, menuitem:active, img:active, table:active, tbody:active, tr:active, td:active, body:active, html:active', prop:'top', value:'1px'},
{input:'a:hover, map:hover, area:hover, link:hover, button:hover, input:hover, menuitem:hover, img:hover, table:hover, tbody:hover, tr:hover, td:hover, body:hover, html:hover', prop:'right', value:'1px'},
// attribute selector
{input:'[id]:active', prop:'bottom', value:'1px'},
{input:'[id]:hover', prop:'left', value:'1px'},
// id selector
{input:'#a:active, #b:active, #map1:active, #c:active, #img1:active, #map2:active, #d:active, #img2:active, #e:active, #f:active, #g:active, #h:active, #i:active, #j:active, #k:active, #l:active, #m:active, #n:active, #o:active, #a_ancestor:active, #table:active, #tbody:active, #tr:active, #td:active, #body:active, #html:active', prop:'caption-side', value:'bottom'},
{input:'#a:hover, #b:hover, #map1:hover, #c:hover, #img1:hover, #map2:hover, #d:hover, #img2:hover, #e:hover, #f:hover, #g:hover, #h:hover, #i:hover, #j:hover, #k:hover, #l:hover, #m:hover, #n:hover, #o:hover, #a_ancestor:hover, #table:hover, #tbody:hover, #tr:hover, #td:hover, #body:hover, #html:hover', prop:'clear', value:'left'},
// class selector
{input:'.t:active, .x:active', prop:'cursor', value:'move'},
{input:'.t:hover, .x:hover', prop:'empty-cells', value:'hide'},
// pseudo-class selector
{input:':lang(en):active', prop:'font-style', value:'italic'},
{input:':lang(en):hover', prop:'font-variant', value:'small-caps'},
// pseudo-element selector
{input:':active::before', prop:'top', value:'1px', pseudoElt:'::before'},
{input:':hover::before', prop:'right', value:'1px', pseudoElt:'::before'},
{input:':active::after', prop:'bottom', value:'1px', pseudoElt:'::after'},
{input:':hover::after', prop:'left', value:'1px', pseudoElt:'::after'},
// as argument
{input:':matches(:active)', prop:'font-weight', value:'bold'},
{input:':matches(:hover)', prop:'list-style-position', value:'inside'},
];
var stylesheet = '';
function serialize(t) {
return t.input + '{' + t.prop + ':' + t.value + '}';
}
links_only.concat(any_elm).forEach(function(t) {
stylesheet += serialize(t);
});
var html = document.getElementById('html_tmpl').textContent.replace('{style}', stylesheet);
var a_doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
var s_doctype = '<!DOCTYPE HTML>';
var q = document.getElementById('quirks').contentWindow;
var a = document.getElementById('almost').contentWindow;
var s = document.getElementById('standards').contentWindow;
q.document.open();
q.document.write(html);
q.document.close();
a.document.open();
a.document.write(a_doctype + html);
a.document.close();
s.document.open();
s.document.write(s_doctype + html);
s.document.close();
q.mode = 'quirks';
a.mode = 'almost';
s.mode = 'standards';
[q, a, s].forEach(function(win) {
win.onmousedown = win.onmouseup = run_tests;
win.onclick = function(e) {
e.preventDefault();
};
});
var test_count = 0;
var total_test_count = q.document.querySelectorAll('.t').length * 3;
function check_matches(id, win, elm, t, expectMatch) {
var prefix = id + ', ' + win.mode + ': ';
// .getComputedStyle can be checked both for pseudo-elements and normal elements
test(function() {
assert_equals(win.getComputedStyle(elm, t.pseudoElt).getPropertyValue(t.prop) === t.value, expectMatch);
}, prefix + 'getComputedStyle(' + elm.id + ') with selector ' + t.input);
// .matches doesn't work with pseudo-elements
if (!t.pseudoElt) {
test(function() {
assert_equals(elm.matches(t.input), expectMatch);
}, prefix + elm.id + '.matches("' + t.input + '")');
}
}
function run_tests(e) {
var elm = e.target;
if (elm.classList.contains('t') && !elm.classList.contains('done')) {
if (!elm.matches('.t:active')) {
return;
}
if (elm.tagName != 'AREA') {
elm.classList.add('done');
} else {
// For <area> we want to style the <img> instead.
if (elm.parentNode.nextElementSibling.tagName != 'IMG') {
throw new Error("<area>'s parent's next element sibling wasn't an <img>");
}
elm.parentNode.nextElementSibling.classList.add('done');
}
var id = elm.id;
var win = elm.ownerDocument.defaultView;
do {
if (win.mode === 'quirks') {
links_only.forEach(function(t) {
var elmIsLink = elm.matches('a[href], area[href], link[href]');
check_matches(id, win, elm, t, elmIsLink);
});
} else {
links_only.forEach(function(t) {
check_matches(id, win, elm, t, true);
});
}
any_elm.forEach(function(t) {
check_matches(id, win, elm, t, true);
});
} while (elm = elm.parentElement);
test_count++;
if (test_count === total_test_count) {
done();
}
}
}
}
</script>
</body>
</html>

View File

@ -13,22 +13,22 @@
<iframe id=standards></iframe>
<script>
setup({explicit_done:true});
var html = "<style id=style></style>";
var a_doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
var s_doctype = '<!DOCTYPE HTML>';
var q = document.getElementById('quirks').contentWindow;
var a = document.getElementById('almost').contentWindow;
var s = document.getElementById('standards').contentWindow;
q.document.open();
q.document.write(html);
q.document.close();
a.document.open();
a.document.write(a_doctype + html);
a.document.close();
s.document.open();
s.document.write(s_doctype + html);
s.document.close();
onload = function() {
var html = "<style id=style></style>";
var a_doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
var s_doctype = '<!DOCTYPE HTML>';
var q = document.getElementById('quirks').contentWindow;
var a = document.getElementById('almost').contentWindow;
var s = document.getElementById('standards').contentWindow;
q.document.open();
q.document.write(html);
q.document.close();
a.document.open();
a.document.write(a_doctype + html);
a.document.close();
s.document.open();
s.document.write(s_doctype + html);
s.document.close();
[q, a, s].forEach(function(win) {
['style', 'test', 'ref', 's_ref'].forEach(function(id) {
win.__proto__.__defineGetter__(id, function() { return win.document.getElementById(id); });

Some files were not shown because too many files have changed in this diff Show More