Update web-platform-tests to revision 41a7d8732d8e5c65728c153d29a34fe9d5192b29

This commit is contained in:
James Graham 2015-05-13 16:20:27 +01:00
parent b05c3fc0c0
commit 5e8b92f3de
77 changed files with 1871 additions and 1412 deletions

File diff suppressed because it is too large Load diff

View file

@ -1 +1 @@
7ee605db117bfc96ef145a1c77d43b704baeacb2 b3b9deafa7ed87bd0649849f3aa729f21c4ff45d

View file

@ -16,7 +16,7 @@ is ongoing that will affect a number of the following tests.</strong>
<script> <script>
test(function() { test(function() {
assert_true("Blob" in window, "window should have a Blob property."); assert_true("Blob" in window, "window should have a Blob property.");
assert_equals(Blob.length, 2, "Blob.length should be 2."); assert_equals(Blob.length, 0, "Blob.length should be 0.");
assert_true(Blob instanceof Function, "Blob should be a function."); assert_true(Blob instanceof Function, "Blob should be a function.");
}, "Blob interface object"); }, "Blob interface object");

View file

@ -16,7 +16,7 @@
var open_rq = createdb(t); var open_rq = createdb(t);
open_rq.onupgradeneeded = function(e) { open_rq.onupgradeneeded = function(e) {
db = event.target.result; db = e.target.result;
var store = db.createObjectStore("test", {keyPath:"pKey"}); var store = db.createObjectStore("test", {keyPath:"pKey"});
store.createIndex("idx", "iKey"); store.createIndex("idx", "iKey");

View file

@ -16,7 +16,7 @@
var open_rq = createdb(t); var open_rq = createdb(t);
open_rq.onupgradeneeded = function(e) { open_rq.onupgradeneeded = function(e) {
db = event.target.result; db = e.target.result;
var store = db.createObjectStore("test", {keyPath:"pKey"}); var store = db.createObjectStore("test", {keyPath:"pKey"});
for(var i = 0; i < records.length; i++) { for(var i = 0; i < records.length; i++) {

View file

@ -29,7 +29,7 @@ open_rq.onsuccess = function(e) {
upgradeneeded_fired = counter++; upgradeneeded_fired = counter++;
}); });
rq.onsuccess = t.step_func(function (e) { rq.onsuccess = t.step_func(function (e) {
assert_equals(versionchange_fired, 0, 'block event fired #') assert_equals(versionchange_fired, 0, 'versionchange event fired #')
assert_equals(blocked_fired, 1, 'block event fired #') assert_equals(blocked_fired, 1, 'block event fired #')
assert_equals(upgradeneeded_fired, 2, 'second upgradeneeded event fired #') assert_equals(upgradeneeded_fired, 2, 'second upgradeneeded event fired #')

View file

@ -1,6 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<meta charset="utf-8"> <meta charset="utf-8">
<title>IDBDatabase.createObjectStore() - Attampt Create Exsists Object Store With Difference keyPath throw ConstraintError </title> <title>IDBDatabase.createObjectStore() - attempting to create an existing object store with a different keyPath throw ConstraintError </title>
<link rel="author" title="Intel" href="http://www.intel.com"> <link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBDatabase-createObjectStore-IDBObjectStore-DOMString-name-IDBObjectStoreParameters-optionalParameters"> <link rel="help" href="https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#widl-IDBDatabase-createObjectStore-IDBObjectStore-DOMString-name-IDBObjectStoreParameters-optionalParameters">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>

View file

@ -47,7 +47,7 @@ should_throw({
function should_work(val) { function should_work(val) {
var t = async_test("Calling open() with version argument 1.5 should not throw.") var t = async_test("Calling open() with version argument 1.5 should not throw.")
var rq = createdb(t) var rq = createdb(t, val)
rq.onupgradeneeded = function() { rq.onupgradeneeded = function() {
t.done() t.done()
} }

View file

@ -25,11 +25,14 @@
txn.objectStore("store") txn.objectStore("store")
.openCursor().onsuccess = this.step_func(function(e) .openCursor().onsuccess = this.step_func(function(e)
{ {
if (e.target.result) if (e.target.result) {
count += 1;
e.target.result.continue() e.target.result.continue()
}
}) })
txn.oncomplete = this.step_func(function() { txn.oncomplete = this.step_func(function() {
assert_equals(count, 100);
this.done() this.done()
}) })
} }

View file

@ -7,7 +7,6 @@
<script src=support.js></script> <script src=support.js></script>
<script> <script>
// TODO XXX DO THE IDBTransaction abort test here here
var db, aborted, var db, aborted,
t = async_test(document.title, {timeout: 10000}), t = async_test(document.title, {timeout: 10000}),
record = { indexedProperty: "bar" }; record = { indexedProperty: "bar" };

View file

@ -36,7 +36,7 @@
// Errors // Errors
db.onerror = fail(t, "db.error"); db.onerror = fail(t, "db.error");
db.abort = fail(t, "db.abort"); db.onabort = fail(t, "db.abort");
setTimeout(t.step_func(deleteDB), 10); setTimeout(t.step_func(deleteDB), 10);
}); });

View file

@ -1,64 +0,0 @@
<!--
Test converted from WebKit:
http://trac.webkit.org/browser/trunk/LayoutTests/storage/indexeddb/resources/interfaces.js
-->
<!DOCTYPE html>
<!-- Submitted from TestTWF Paris -->
<meta charset=utf-8>
<title>Test IndexedDB's interfaces</title>
<link rel=author href="mailto:romain.huet@gmail.com" title="Romain Huet">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=support.js></script>
<script>
test(function() {
assert_true('IDBCursor' in self);
}, "Test IDBCursor");
test(function() {
assert_true('IDBCursorWithValue' in self);
}, "Test IDBCursorWithValue");
test(function() {
assert_true('IDBDatabase' in self);
}, "Test IDBDatabase");
test(function() {
assert_true('IDBFactory' in self);
}, "Test IDBFactory");
test(function() {
assert_true('IDBIndex' in self);
}, "Test IDBIndex");
test(function() {
assert_true('IDBKeyRange' in self);
}, "Test IDBKeyRange");
test(function() {
assert_true('IDBObjectStore' in self);
}, "Test IDBObjectStore");
test(function() {
assert_true('IDBOpenDBRequest' in self);
}, "Test IDBOpenDBRequest");
test(function() {
assert_true('IDBRequest' in self);
}, "Test IDBRequest");
test(function() {
assert_true('IDBTransaction' in self);
}, "Test IDBTransaction");
test(function() {
assert_true('IDBVersionChangeEvent' in self);
}, "Test IDBVersionChangeEvent");
</script>
<div id=log></div>

View file

@ -267,7 +267,7 @@ GitHub UI. Below is one method and others can be found on
4. Wait for feedback on your pull request and once your pull request is 4. Wait for feedback on your pull request and once your pull request is
accepted, detele youre branch (see ' accepted, delete your branch (see '
[When Pull Request is Accepted][cleanup]'). [When Pull Request is Accepted][cleanup]').
That's it! If you're currently at a Test the Web Forward event, find an That's it! If you're currently at a Test the Web Forward event, find an

View file

@ -14,8 +14,18 @@ function testNode(create, type) {
assert_throws("INDEX_SIZE_ERR", function() { node.deleteData(5, 10) }) assert_throws("INDEX_SIZE_ERR", function() { node.deleteData(5, 10) })
assert_throws("INDEX_SIZE_ERR", function() { node.deleteData(5, 0) }) assert_throws("INDEX_SIZE_ERR", function() { node.deleteData(5, 0) })
assert_throws("INDEX_SIZE_ERR", function() { node.deleteData(-1, 10) })
assert_throws("INDEX_SIZE_ERR", function() { node.deleteData(-1, 0) })
}, type + ".deleteData() out of bounds") }, type + ".deleteData() out of bounds")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.deleteData(0, 2)
assert_equals(node.data, "st")
}, type + ".deleteData() at the start")
test(function() { test(function() {
var node = create() var node = create()
assert_equals(node.data, "test") assert_equals(node.data, "test")
@ -32,6 +42,33 @@ function testNode(create, type) {
assert_equals(node.data, "tst") assert_equals(node.data, "tst")
}, type + ".deleteData() in the middle") }, type + ".deleteData() in the middle")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.deleteData(2, 0)
assert_equals(node.data, "test")
node.deleteData(0, 0)
assert_equals(node.data, "test")
}, type + ".deleteData() with zero count")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.deleteData(2, -1)
assert_equals(node.data, "te")
}, type + ".deleteData() with small negative count")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.deleteData(1, -0x100000000 + 2)
assert_equals(node.data, "tt")
}, type + ".deleteData() with large negative count")
test(function() { test(function() {
var node = create() var node = create()
node.data = "This is the character data test, append more 資料,更多測試資料"; node.data = "This is the character data test, append more 資料,更多測試資料";

View file

@ -16,6 +16,38 @@ function testNode(create, type) {
assert_throws("INDEX_SIZE_ERR", function() { node.insertData(5, "") }) assert_throws("INDEX_SIZE_ERR", function() { node.insertData(5, "") })
}, type + ".insertData() out of bounds") }, type + ".insertData() out of bounds")
test(function() {
var node = create()
assert_equals(node.data, "test")
assert_throws("INDEX_SIZE_ERR", function() { node.insertData(-1, "x") })
assert_throws("INDEX_SIZE_ERR", function() { node.insertData(-0x100000000 + 5, "x") })
}, type + ".insertData() negative out of bounds")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.insertData(-0x100000000 + 2, "X")
assert_equals(node.data, "teXst")
}, type + ".insertData() negative in bounds")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.insertData(0, "")
assert_equals(node.data, "test")
}, type + ".insertData('')")
test(function() {
var node = create()
assert_equals(node.data, "test")
node.insertData(0, "X")
assert_equals(node.data, "Xtest")
}, type + ".insertData() at the start")
test(function() { test(function() {
var node = create() var node = create()
assert_equals(node.data, "test") assert_equals(node.data, "test")

View file

@ -0,0 +1,53 @@
<!doctype html>
<meta charset=utf-8>
<title>Text.splitText()</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-text-splittextoffset">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var text = document.createTextNode("camembert");
assert_throws("INDEX_SIZE_ERR", function () { text.splitText(10) });
}, "Split text after end of data");
test(function() {
var text = document.createTextNode("");
var new_text = text.splitText(0);
assert_equals(text.data, "");
assert_equals(new_text.data, "");
}, "Split empty text");
test(function() {
var text = document.createTextNode("comté");
var new_text = text.splitText(0);
assert_equals(text.data, "");
assert_equals(new_text.data, "comté");
}, "Split text at beginning");
test(function() {
var text = document.createTextNode("comté");
var new_text = text.splitText(5);
assert_equals(text.data, "comté");
assert_equals(new_text.data, "");
}, "Split text at end");
test(function() {
var text = document.createTextNode("comté");
var new_text = text.splitText(3);
assert_equals(text.data, "com");
assert_equals(new_text.data, "té");
assert_equals(new_text.parentNode, null);
}, "Split root");
test(function() {
var parent = document.createElement('div');
var text = document.createTextNode("bleu");
parent.appendChild(text);
var new_text = text.splitText(2);
assert_equals(text.data, "bl");
assert_equals(new_text.data, "eu");
assert_equals(text.nextSibling, new_text);
assert_equals(new_text.parentNode, parent);
}, "Split child");
</script>

View file

@ -0,0 +1,3 @@
def main(request, response):
response.headers.set("Content-Type", "text/plain;charset=" + request.GET.first("label"))
response.content = "hello encoding"

View file

@ -86,7 +86,7 @@
async_test(function(t) { async_test(function(t) {
var frame = document.createElement("iframe"), var frame = document.createElement("iframe"),
name = compatibility_names[encoding.name] || encoding.name; name = compatibility_names[encoding.name] || encoding.name;
frame.src = "resources/single-byte-raw.py?label=" + label frame.src = "resources/text-plain-charset.py?label=" + label
frame.onload = t.step_func_done(function() { frame.onload = t.step_func_done(function() {
assert_equals(frame.contentDocument.characterSet, name) assert_equals(frame.contentDocument.characterSet, name)
assert_equals(frame.contentDocument.inputEncoding, name) assert_equals(frame.contentDocument.inputEncoding, name)

View file

@ -63,9 +63,7 @@ test(function() {
assert_equals(img2.id, "test4"); assert_equals(img2.id, "test4");
assert_false("test4" in document, '"test4" in document should be false'); assert_false("test4" in document, '"test4" in document should be false');
var collection = document.test4; assert_equals(document.test4, undefined);
assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection");
assert_array_equals(collection, [img1, img2]);
}, "If there are two imgs, nothing should be returned. (id)"); }, "If there are two imgs, nothing should be returned. (id)");
test(function() { test(function() {

View file

@ -373,7 +373,7 @@ ReflectionTests.typeMap = {
{toString:function() {return 2;}, valueOf: null}, {toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}], {valueOf:function() {return 3;}}],
"domExpected": function(val) { "domExpected": function(val) {
var parsed = ReflectionTests.parseNonneg(val + ""); var parsed = ReflectionTests.parseNonneg(String(val));
if (parsed === false || parsed > maxInt || parsed < minInt) { if (parsed === false || parsed > maxInt || parsed < minInt) {
return null; return null;
} }
@ -409,7 +409,7 @@ ReflectionTests.typeMap = {
{toString:function() {return 2;}, valueOf: null}, {toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}], {valueOf:function() {return 3;}}],
"domExpected": function(val) { "domExpected": function(val) {
var parsed = ReflectionTests.parseNonneg(val + ""); var parsed = ReflectionTests.parseNonneg(String(val));
// Note maxInt, not maxUnsigned. // Note maxInt, not maxUnsigned.
if (parsed === false || parsed < 0 || parsed > maxInt) { if (parsed === false || parsed < 0 || parsed > maxInt) {
return null; return null;
@ -450,7 +450,7 @@ ReflectionTests.typeMap = {
{toString:function() {return 2;}, valueOf: null}, {toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}], {valueOf:function() {return 3;}}],
"domExpected": function(val) { "domExpected": function(val) {
var parsed = ReflectionTests.parseNonneg(val + ""); var parsed = ReflectionTests.parseNonneg(String(val));
// Note maxInt, not maxUnsigned. // Note maxInt, not maxUnsigned.
if (parsed === false || parsed < 1 || parsed > maxInt) { if (parsed === false || parsed < 1 || parsed > maxInt) {
return null; return null;
@ -696,7 +696,7 @@ ReflectionTests.doReflects = function(data, idlName, idlObj, domName, domObj) {
} }
try { try {
domObj.setAttribute(domName, domTests[i]); domObj.setAttribute(domName, domTests[i]);
ReflectionHarness.test(domObj.getAttribute(domName), domTests[i] + "", "setAttribute() to " + ReflectionHarness.stringRep(domTests[i]) + " followed by getAttribute()"); ReflectionHarness.test(domObj.getAttribute(domName), String(domTests[i]), "setAttribute() to " + ReflectionHarness.stringRep(domTests[i]) + " followed by getAttribute()");
ReflectionHarness.test(idlObj[idlName], domExpected[i], "setAttribute() to " + ReflectionHarness.stringRep(domTests[i]) + " followed by IDL get"); ReflectionHarness.test(idlObj[idlName], domExpected[i], "setAttribute() to " + ReflectionHarness.stringRep(domTests[i]) + " followed by IDL get");
if (ReflectionHarness.catchUnexpectedExceptions) { if (ReflectionHarness.catchUnexpectedExceptions) {
ReflectionHarness.success(); ReflectionHarness.success();

View file

@ -10,18 +10,18 @@
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<meta name='flags' content='dom'> <meta name='flags' content='dom'>
<style type='text/css'> <style type='text/css'>
#colonlangcontroltest { color: red; font-weight: bold; width: 400px; } #colonlangcontroltest { color: red; font-weight: bold; width: 400px; }
#colonlangcontroltest:lang(xx) { display:none; } #colonlangcontroltest:lang(xx) { display:none; }
.test div { width: 50px; } .test div { width: 50px; }
#box:lang(ko) { width: 100px; } #box:lang(ko) { width: 100px; }
#box:lang(zh) { width: 100px; } #box:lang(zh) { width: 100px; }
#box:lang(ja) { width: 100px; } #box:lang(ja) { width: 100px; }
/* styling for debugging related notes */ /* styling for debugging related notes */
.notes span:lang(ko) { background-color: #0000FF; color: white; padding: 0 5px; } .notes span:lang(ko) { background-color: #0000FF; color: white; padding: 0 5px; }
.notes span:lang(zh) { background-color: #0000FF; color: white; padding: 0 5px; } .notes span:lang(zh) { background-color: #0000FF; color: white; padding: 0 5px; }
.notes span:lang(ja) { background-color: #0000FF; color: white; padding: 0 5px; } .notes span:lang(ja) { background-color: #0000FF; color: white; padding: 0 5px; }
</style> </style>
</head> </head>

View file

@ -4,9 +4,9 @@
<head> <head>
<title>Pattern Attribute</title> <title>Pattern Attribute</title>
<meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" /> <meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" />
<link rel="author" title="Fabrice Clari" href="mailto:f.clari@inno-group.com"> <link rel="author" title="Fabrice Clari" href="mailto:f.clari@inno-group.com">
<link rel="author" title="Dimitri Bocquet" href="mailto:Dimitri.Bocquet@mosquito-fp7.eu"> <link rel="author" title="Dimitri Bocquet" href="mailto:Dimitri.Bocquet@mosquito-fp7.eu">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-input-pattern"> <link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-input-pattern">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
</head> </head>
@ -14,20 +14,20 @@
<body> <body>
<h1>Pattern Attribute</h1> <h1>Pattern Attribute</h1>
<div style="display: none"> <div style="display: none">
<input pattern="[a-z]{3}" value="abcd" title="three letters max"/> <input pattern="[a-z]{3}" value="abcd" title="three letters max"/>
</div> </div>
<div id="log"> <div id="log">
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
test(function() {assert_equals(document.getElementsByTagName("input")[0].getAttribute("pattern"), "[a-z]{3}")}, "pattern attribute support on input element"); test(function() {assert_equals(document.getElementsByTagName("input")[0].getAttribute("pattern"), "[a-z]{3}")}, "pattern attribute support on input element");
</script> </script>
</body> </body>

View file

@ -4,9 +4,9 @@
<head> <head>
<title>Required Attribute</title> <title>Required Attribute</title>
<meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" /> <meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" />
<link rel="author" title="Fabrice Clari" href="mailto:f.clari@inno-group.com"> <link rel="author" title="Fabrice Clari" href="mailto:f.clari@inno-group.com">
<link rel="author" title="Dimitri Bocquet" href="mailto:Dimitri.Bocquet@mosquito-fp7.eu"> <link rel="author" title="Dimitri Bocquet" href="mailto:Dimitri.Bocquet@mosquito-fp7.eu">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-input-required"> <link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-input-required">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
</head> </head>
@ -14,20 +14,20 @@
<body> <body>
<h1>Required Attribute</h1> <h1>Required Attribute</h1>
<div style="display: none"> <div style="display: none">
<input type="text" required="required" /> <input type="text" required="required" />
</div> </div>
<div id="log"> <div id="log">
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
test(function() {assert_equals(document.getElementsByTagName("input")[0].getAttribute("required"), "required")}, "required attribute support on input element"); test(function() {assert_equals(document.getElementsByTagName("input")[0].getAttribute("required"), "required")}, "required attribute support on input element");
</script> </script>
</body> </body>

View file

@ -4,9 +4,9 @@
<head> <head>
<title>Search Input</title> <title>Search Input</title>
<meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" /> <meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" />
<link rel="author" title="Fabrice Clari" href="mailto:f.clari@inno-group.com"> <link rel="author" title="Fabrice Clari" href="mailto:f.clari@inno-group.com">
<link rel="author" title="Dimitri Bocquet" href="mailto:Dimitri.Bocquet@mosquito-fp7.eu"> <link rel="author" title="Dimitri Bocquet" href="mailto:Dimitri.Bocquet@mosquito-fp7.eu">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-input-element"> <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-input-element">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
</head> </head>
@ -14,21 +14,21 @@
<body> <body>
<h1>Search Input</h1> <h1>Search Input</h1>
<input type="search" style="display:none" placeholder="Search..." /> <input type="search" style="display:none" placeholder="Search..." />
<div id="log"> <div id="log">
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
test(function() {assert_equals(document.getElementsByTagName("input")[0].type, "search")}, "search type support on input element", { test(function() {assert_equals(document.getElementsByTagName("input")[0].type, "search")}, "search type support on input element", {
"help" : "https://html.spec.whatwg.org/multipage/#dom-input-type" }); "help" : "https://html.spec.whatwg.org/multipage/#dom-input-type" });
test(function() {assert_equals(document.getElementsByTagName("input")[0].placeholder, "Search...")}, "placeholder attribute support on input element", { test(function() {assert_equals(document.getElementsByTagName("input")[0].placeholder, "Search...")}, "placeholder attribute support on input element", {
"help" : "https://html.spec.whatwg.org/multipage/#dom-input-placeholder" }); "help" : "https://html.spec.whatwg.org/multipage/#dom-input-placeholder" });
</script> </script>
</body> </body>

View file

@ -1,84 +1,84 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Input tel</title> <title>Input tel</title>
<link rel="author" title="Kazuki Kanamori" href="mailto:yogurito@gmail.com"> <link rel="author" title="Kazuki Kanamori" href="mailto:yogurito@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#telephone-state-(type=tel)"> <link rel="help" href="https://html.spec.whatwg.org/multipage/#telephone-state-(type=tel)">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
</head> </head>
<body> <body>
<h1>Input tel</h1> <h1>Input tel</h1>
<input type="tel" id="novalue" /> <input type="tel" id="novalue" />
<input type="tel" id="value_with_LF" value="0&#x000A;1" /> <input type="tel" id="value_with_LF" value="0&#x000A;1" />
<input type="tel" id="value_with_CR" value="0&#x000D;1" /> <input type="tel" id="value_with_CR" value="0&#x000D;1" />
<input type="tel" id="value_with_CRLF" value="0&#x000A;&#x000D;1" /> <input type="tel" id="value_with_CRLF" value="0&#x000A;&#x000D;1" />
<div id="log"> <div id="log">
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var element = document.getElementById('novalue'); var element = document.getElementById('novalue');
test(function(){ test(function(){
assert_equals(element.type, 'tel'); assert_equals(element.type, 'tel');
}, 'tel type supported on input element'); }, 'tel type supported on input element');
test(function(){ test(function(){
element.value = '0\u000A1'; element.value = '0\u000A1';
assert_equals(element.value, '01'); assert_equals(element.value, '01');
}, 'User agents must not allow users to insert "LF" (U+000A)'); }, 'User agents must not allow users to insert "LF" (U+000A)');
test(function(){ test(function(){
element.value = '0\u000D1'; element.value = '0\u000D1';
assert_equals(element.value, '01'); assert_equals(element.value, '01');
}, 'User agents must not allow users to insert "CR" (U+000D)'); }, 'User agents must not allow users to insert "CR" (U+000D)');
element = document.getElementById('value_with_LF'); element = document.getElementById('value_with_LF');
test(function(){ test(function(){
assert_equals(element.value, '01'); assert_equals(element.value, '01');
}, 'The value attribute, if specified, must have a value that contains no "LF" (U+000A)'); }, 'The value attribute, if specified, must have a value that contains no "LF" (U+000A)');
element = document.getElementById('value_with_CR'); element = document.getElementById('value_with_CR');
test(function(){ test(function(){
assert_equals(element.value, '01'); assert_equals(element.value, '01');
}, 'The value attribute, if specified, must have a value that contains no "CR" (U+000D)'); }, 'The value attribute, if specified, must have a value that contains no "CR" (U+000D)');
test(function(){ test(function(){
element = document.getElementById('novalue'); element = document.getElementById('novalue');
element.value = '0\u000D\u000A1'; element.value = '0\u000D\u000A1';
assert_equals(element.value, '01'); assert_equals(element.value, '01');
element = document.getElementById('value_with_CRLF'); element = document.getElementById('value_with_CRLF');
assert_equals(element.value, '01'); assert_equals(element.value, '01');
}, 'The value sanitization algorithm is as follows: Strip line breaks from the value'); }, 'The value sanitization algorithm is as follows: Strip line breaks from the value');
element = document.getElementById('novalue'); element = document.getElementById('novalue');
test(function(){ test(function(){
element.value = '+811234'; element.value = '+811234';
assert_equals(element.value, '+811234'); assert_equals(element.value, '+811234');
}, 'Element can accept the phone number with plus sign(country code)'); }, 'Element can accept the phone number with plus sign(country code)');
test(function(){ test(function(){
element.value = '1234#5678'; element.value = '1234#5678';
assert_equals(element.value, '1234#5678'); assert_equals(element.value, '1234#5678');
}, 'Element can accept the phone number with hash mark(extension number)'); }, 'Element can accept the phone number with hash mark(extension number)');
test(function(){ test(function(){
element.value = '123-456-789'; element.value = '123-456-789';
assert_equals(element.value, '123-456-789'); assert_equals(element.value, '123-456-789');
}, 'Element can accept the phone number with hyphen'); }, 'Element can accept the phone number with hyphen');
test(function(){ test(function(){
element.value = '123.456.789'; element.value = '123.456.789';
assert_equals(element.value, '123.456.789'); assert_equals(element.value, '123.456.789');
}, 'Element can accept the phone number with dots'); }, 'Element can accept the phone number with dots');
test(function(){ test(function(){
element.value = '1 23 4'; element.value = '1 23 4';
assert_equals(element.value, '1 23 4'); assert_equals(element.value, '1 23 4');
}, 'Element can accept the phone number with whitespace'); }, 'Element can accept the phone number with whitespace');
test(function(){ test(function(){
element.value = ' 1234 '; element.value = ' 1234 ';
assert_equals(element.value, ' 1234 '); assert_equals(element.value, ' 1234 ');
}, 'Element can accept the phone number with leading & following whitespaces'); }, 'Element can accept the phone number with leading & following whitespaces');
test(function(){ test(function(){
element.value = '(03)12345678'; element.value = '(03)12345678';
assert_equals(element.value, '(03)12345678'); assert_equals(element.value, '(03)12345678');
}, 'Element can accept the phone number with parentheses(area code)'); }, 'Element can accept the phone number with parentheses(area code)');
</script> </script>
</body> </body>
</html> </html>

View file

@ -4,43 +4,43 @@
<head> <head>
<title>Input Time</title> <title>Input Time</title>
<meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" /> <meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-input-element"> <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-input-element">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
</head> </head>
<body> <body>
<h1>Input Time</h1> <h1>Input Time</h1>
<div style="display:none;"> <div style="display:none;">
<input type="time "id="chkDefaultValue" /> <input type="time "id="chkDefaultValue" />
<input type="time" id="chkStep" /> <input type="time" id="chkStep" />
<input type="time" id="chkSetValueTest" /> <input type="time" id="chkSetValueTest" />
<input type="time" id="chkSupportAttribute" min="01:01:01.001" max="12:12:12.012" step="600" /> <input type="time" id="chkSupportAttribute" min="01:01:01.001" max="12:12:12.012" step="600" />
</div> </div>
<div id="log"> <div id="log">
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
/* check default value */ /* check default value */
test(function(){ assert_equals(document.getElementById("chkDefaultValue").value, ""); test(function(){ assert_equals(document.getElementById("chkDefaultValue").value, "");
}, "time element of default time value"); }, "time element of default time value");
test(function(){assert_equals(document.getElementById('chkStep').step, ""); test(function(){assert_equals(document.getElementById('chkStep').step, "");
} , "step attribute on default value check"); }, "step attribute on default value check");
test(function(){assert_equals(document.getElementById('chkDefaultValue').max, ""); test(function(){assert_equals(document.getElementById('chkDefaultValue').max, "");
} , "max attribute on default value check") }, "max attribute on default value check")
test(function(){assert_equals(document.getElementById('chkDefaultValue').max, ""); test(function(){assert_equals(document.getElementById('chkDefaultValue').max, "");
} , "min attribute on default value check") }, "min attribute on default value check")
/* simple attribute test*/ /* simple attribute test*/
test(function(){assert_equals(document.getElementById("chkSupportAttribute").type,"time");} test(function(){assert_equals(document.getElementById("chkSupportAttribute").type,"time");}
, "type attribute support on input element"); , "type attribute support on input element");
test(function(){assert_equals(document.getElementById('chkSupportAttribute').min, "01:01:01.001")} test(function(){assert_equals(document.getElementById('chkSupportAttribute').min, "01:01:01.001")}
, "max attribute support on input element"); , "max attribute support on input element");
test(function(){assert_equals(document.getElementById('chkSupportAttribute').max, "12:12:12.012")} test(function(){assert_equals(document.getElementById('chkSupportAttribute').max, "12:12:12.012")}
, "min attribute support on input element"); , "min attribute support on input element");
test(function(){assert_equals(document.getElementById("chkSupportAttribute").step, "600")} test(function(){assert_equals(document.getElementById("chkSupportAttribute").step, "600")}
, "step attribute support on input element"); , "step attribute support on input element");
/* check step up and down */ /* check step up and down */
var _StepTest = document.getElementById("chkStep"); var _StepTest = document.getElementById("chkStep");
@ -48,160 +48,160 @@ test(function(){ assert_true(typeof(_StepTest.stepUp) ==="function" ) } , "ste
test(function(){ assert_true(typeof(_StepTest.stepDown) ==="function" ) } , "stepDown function support on input Element"); test(function(){ assert_true(typeof(_StepTest.stepDown) ==="function" ) } , "stepDown function support on input Element");
test(function(){ test(function(){
_StepTest.value = "12:00"; _StepTest.value = "12:00";
_StepTest.step = ""; _StepTest.step = "";
_StepTest.stepUp(); _StepTest.stepUp();
assert_equals(_StepTest.value,"12:01"); assert_equals(_StepTest.value,"12:01");
} , "stepUp step value empty on default step value "); } , "stepUp step value empty on default step value ");
test(function(){ test(function(){
_StepTest.value = "12:00"; _StepTest.value = "12:00";
_StepTest.step = ""; _StepTest.step = "";
_StepTest.stepDown(); _StepTest.stepDown();
assert_equals(_StepTest.value,"11:59"); assert_equals(_StepTest.value,"11:59");
}, "stepDown step value empty default step value"); }, "stepDown step value empty default step value");
test(function(){ test(function(){
_StepTest.value = "12:00"; _StepTest.value = "12:00";
_StepTest.step = "-600"; _StepTest.step = "-600";
_StepTest.stepUp(); _StepTest.stepUp();
assert_equals(_StepTest.value, "12:01"); assert_equals(_StepTest.value, "12:01");
},"stepUp on step value minus"); },"stepUp on step value minus");
test(function(){ test(function(){
_StepTest.value = "12:00"; _StepTest.value = "12:00";
_StepTest.step = "-600"; _StepTest.step = "-600";
_StepTest.stepDown(); _StepTest.stepDown();
assert_equals(_StepTest.value, "11:59"); assert_equals(_StepTest.value, "11:59");
},"stepDown on step value minus"); },"stepDown on step value minus");
test(function(){ test(function(){
_StepTest.value = "12:00"; _StepTest.value = "12:00";
_StepTest.step = "0"; _StepTest.step = "0";
_StepTest.stepUp(); _StepTest.stepUp();
assert_equals(_StepTest.value, "12:01"); assert_equals(_StepTest.value, "12:01");
} , "stepUp on step value zero "); } , "stepUp on step value zero ");
test(function(){ test(function(){
_StepTest.value = "12:00"; _StepTest.value = "12:00";
_StepTest.step = "0"; _StepTest.step = "0";
_StepTest.stepDown(); _StepTest.stepDown();
assert_equals(_StepTest.value, "11:59"); assert_equals(_StepTest.value, "11:59");
} , "stepDown on step value zero "); } , "stepDown on step value zero ");
test(function(){ test(function(){
_StepTest.value = "00:00"; _StepTest.value = "00:00";
_StepTest.step = "86399"; _StepTest.step = "86399";
_StepTest.stepUp(); _StepTest.stepUp();
assert_equals(_StepTest.value, "23:59:59"); assert_equals(_StepTest.value, "23:59:59");
} , "stepUp on step value 24 hour"); } , "stepUp on step value 24 hour");
test(function(){ test(function(){
_StepTest.value = "23:59:59"; _StepTest.value = "23:59:59";
_StepTest.step = "86399"; _StepTest.step = "86399";
_StepTest.stepDown(); _StepTest.stepDown();
assert_equals(_StepTest.value, "00:00:00"); assert_equals(_StepTest.value, "00:00:00");
} , "stepDown on step value 24 hour "); } , "stepDown on step value 24 hour ");
test(function(){ test(function(){
_StepTest.value = "12:00"; _StepTest.value = "12:00";
_StepTest.step = "3600"; _StepTest.step = "3600";
_StepTest.stepUp(); _StepTest.stepUp();
assert_equals(_StepTest.value, "13:00"); assert_equals(_StepTest.value, "13:00");
} , "stepUp on step value hour "); } , "stepUp on step value hour ");
test(function(){ test(function(){
_StepTest.value = "12:00"; _StepTest.value = "12:00";
_StepTest.step = "3600"; _StepTest.step = "3600";
_StepTest.stepDown(); _StepTest.stepDown();
assert_equals(_StepTest.value, "11:00"); assert_equals(_StepTest.value, "11:00");
} , "stepDown on step value hour "); } , "stepDown on step value hour ");
test(function(){ test(function(){
_StepTest.value = "12:00"; _StepTest.value = "12:00";
_StepTest.step = "1"; _StepTest.step = "1";
_StepTest.stepUp(); _StepTest.stepUp();
assert_equals(_StepTest.value, "12:00:01"); assert_equals(_StepTest.value, "12:00:01");
} , "stepUp on step value second "); } , "stepUp on step value second ");
test(function(){ test(function(){
_StepTest.value = "12:00"; _StepTest.value = "12:00";
_StepTest.step = "1"; _StepTest.step = "1";
_StepTest.stepDown(); _StepTest.stepDown();
assert_equals(_StepTest.value, "11:59:59"); assert_equals(_StepTest.value, "11:59:59");
} , "stepDown on step value second "); } , "stepDown on step value second ");
test(function(){ test(function(){
_StepTest.value = "12:00"; _StepTest.value = "12:00";
_StepTest.step = "0.001"; _StepTest.step = "0.001";
_StepTest.stepUp(); _StepTest.stepUp();
assert_equals(_StepTest.value, "12:00:00.001"); assert_equals(_StepTest.value, "12:00:00.001");
} , "stepUp on step value miri second "); } , "stepUp on step value miri second ");
test(function(){ test(function(){
_StepTest.value = "12:00"; _StepTest.value = "12:00";
_StepTest.step = "0.001"; _StepTest.step = "0.001";
_StepTest.stepDown(); _StepTest.stepDown();
assert_equals(_StepTest.value, "11:59:59.999"); assert_equals(_StepTest.value, "11:59:59.999");
} , "stepDown on step value miri second "); } , "stepDown on step value miri second ");
test(function(){ test(function(){
_StepTest.value = "13:00:00"; _StepTest.value = "13:00:00";
_StepTest.step = "1"; _StepTest.step = "1";
_StepTest.stepUp(2); _StepTest.stepUp(2);
assert_equals(_StepTest.value, "13:00:02"); assert_equals(_StepTest.value, "13:00:02");
}, "stepUp argment 2 times"); }, "stepUp argment 2 times");
test(function(){ test(function(){
_StepTest.value = "13:00:00"; _StepTest.value = "13:00:00";
_StepTest.step = "1"; _StepTest.step = "1";
_StepTest.stepDown(2); _StepTest.stepDown(2);
assert_equals(_StepTest.value, "12:59:58"); assert_equals(_StepTest.value, "12:59:58");
}, "stepDown argment 2 times"); }, "stepDown argment 2 times");
test(function(){ test(function(){
_StepTest.max = "15:00"; _StepTest.max = "15:00";
_StepTest.value = "15:00"; _StepTest.value = "15:00";
_StepTest.stepUp(); _StepTest.stepUp();
assert_equals(_StepTest.value, "15:00"); assert_equals(_StepTest.value, "15:00");
_StepTest.max = ""; _StepTest.max = "";
} , "stepUp stop because it exceeds the maximum value"); } , "stepUp stop because it exceeds the maximum value");
test(function(){ test(function(){
_StepTest.min = "13:00"; _StepTest.min = "13:00";
_StepTest.value = "13:00"; _StepTest.value = "13:00";
_StepTest.stepDown(); _StepTest.stepDown();
assert_equals(_StepTest.value, "13:00"); assert_equals(_StepTest.value, "13:00");
_StepTest.min=""; _StepTest.min="";
} , "stepDown Stop so lower than the minimum value"); } , "stepDown Stop so lower than the minimum value");
test(function(){ test(function(){
_StepTest.max = "15:01"; _StepTest.max = "15:01";
_StepTest.value = "15:00"; _StepTest.value = "15:00";
_StepTest.step = "120"; _StepTest.step = "120";
_StepTest.stepUp(); _StepTest.stepUp();
assert_equals(_StepTest.value, "15:01"); assert_equals(_StepTest.value, "15:01");
_StepTest.max = ""; _StepTest.max = "";
} , "stop at border on stepUp"); } , "stop at border on stepUp");
test(function(){ test(function(){
_StepTest.min = "12:59"; _StepTest.min = "12:59";
_StepTest.value = "13:00"; _StepTest.value = "13:00";
_StepTest.step = "120"; _StepTest.step = "120";
_StepTest.stepDown(); _StepTest.stepDown();
assert_equals(_StepTest.value, "12:59"); assert_equals(_StepTest.value, "12:59");
_StepTest.min=""; _StepTest.min="";
} , "stop at border on stepDown"); } , "stop at border on stepDown");
test(function(){ test(function(){
_StepTest.value = ""; _StepTest.value = "";
_StepTest.step = "60"; _StepTest.step = "60";
_StepTest.stepUp(); _StepTest.stepUp();
assert_equals(_StepTest.value, "00:01"); assert_equals(_StepTest.value, "00:01");
} , " empty value of stepUp"); } , " empty value of stepUp");
/* set value test */ /* set value test */
test(function(){ test(function(){
var _time = document.getElementById("chkSetValueTest"); var _time = document.getElementById("chkSetValueTest");
_time.value = "12:00:00.000"; _time.value = "12:00:00.000";
assert_equals(_time.value, "12:00:00.000"); assert_equals(_time.value, "12:00:00.000");
_time.value = "hh:mi:ss.sss"; _time.value = "hh:mi:ss.sss";
assert_equals(_time.value, ""); assert_equals(_time.value, "");
}, "set value on not time format value"); }, "set value on not time format value");
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,59 +1,59 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Input url</title> <title>Input url</title>
<link rel="author" title="Hyeonseok Shin" href="mailto:hyeonseok@gmail.com"> <link rel="author" title="Hyeonseok Shin" href="mailto:hyeonseok@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#url-state-%28type=url%29"> <link rel="help" href="https://html.spec.whatwg.org/multipage/#url-state-%28type=url%29">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
</head> </head>
<body> <body>
<h1>Input url</h1> <h1>Input url</h1>
<div style="display: none"> <div style="display: none">
<input type="url" id="type_support" /> <input type="url" id="type_support" />
<input type="url" id="set_value_LF" /> <input type="url" id="set_value_LF" />
<input type="url" id="set_value_CR" /> <input type="url" id="set_value_CR" />
<input type="url" id="set_value_CRLF" /> <input type="url" id="set_value_CRLF" />
<input type="url" id="value_with_CRLF" value="a&#x000D;&#x000A;a" /> <input type="url" id="value_with_CRLF" value="a&#x000D;&#x000A;a" />
<input type="url" id="value_with_leading_trailing_white_space" value=" aa " /> <input type="url" id="value_with_leading_trailing_white_space" value=" aa " />
<input type="url" id="value_with_leading_trailing_inner_white_space" value=" a a " /> <input type="url" id="value_with_leading_trailing_inner_white_space" value=" a a " />
</div> </div>
<div id="log"> <div id="log">
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
test(function(){ test(function(){
var element = document.getElementById('type_support'); var element = document.getElementById('type_support');
assert_equals(element.type, 'url'); assert_equals(element.type, 'url');
}, 'url type supported on input element'); }, 'url type supported on input element');
test(function(){ test(function(){
var element = document.getElementById('set_value_LF'); var element = document.getElementById('set_value_LF');
element.value = 'a\u000Aa'; element.value = 'a\u000Aa';
assert_equals(element.value, 'aa'); assert_equals(element.value, 'aa');
element = document.getElementById('set_value_CR'); element = document.getElementById('set_value_CR');
element.value = 'a\u000Da'; element.value = 'a\u000Da';
assert_equals(element.value, 'aa'); assert_equals(element.value, 'aa');
element = document.getElementById('set_value_CRLF'); element = document.getElementById('set_value_CRLF');
element.value = 'a\u000D\u000Aa'; element.value = 'a\u000D\u000Aa';
assert_equals(element.value, 'aa'); assert_equals(element.value, 'aa');
}, 'The value must not be set with "LF" (U+000A) or "CR" (U+000D)'); }, 'The value must not be set with "LF" (U+000A) or "CR" (U+000D)');
test(function(){ test(function(){
var element = document.getElementById('value_with_CRLF'); var element = document.getElementById('value_with_CRLF');
assert_equals(element.value, 'aa'); assert_equals(element.value, 'aa');
}, 'The value sanitization algorithm is as follows: Strip line breaks from the value'); }, 'The value sanitization algorithm is as follows: Strip line breaks from the value');
test(function(){ test(function(){
var element = document.getElementById('value_with_leading_trailing_white_space'); var element = document.getElementById('value_with_leading_trailing_white_space');
assert_equals(element.value, 'aa'); assert_equals(element.value, 'aa');
element = document.getElementById('value_with_leading_trailing_inner_white_space'); element = document.getElementById('value_with_leading_trailing_inner_white_space');
assert_equals(element.value, 'a a'); assert_equals(element.value, 'a a');
}, 'The value sanitization algorithm is as follows: Strip leading and trailing whitespace from the value.'); }, 'The value sanitization algorithm is as follows: Strip leading and trailing whitespace from the value.');
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,14 +1,14 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>Template tag with children div tags inside</title> <title>Template tag with children div tags inside</title>
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru"/> <link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru"/>
</head> </head>
<body> <body>
<p>Template tag with div tags inside</p> <p>Template tag with div tags inside</p>
<template> <template>
<div>This is div inside template</div> <div>This is div inside template</div>
<div>This is another div inside template</div> <div>This is another div inside template</div>
</template> </template>
</body> </body>
</html> </html>

View file

@ -1,16 +1,16 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>Template tag with children div tags inside another template tag</title> <title>Template tag with children div tags inside another template tag</title>
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru"/> <link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru"/>
</head> </head>
<body> <body>
<p>Template tag with children div tags inside another template tag</p> <p>Template tag with children div tags inside another template tag</p>
<template> <template>
<template> <template>
<div>This is div inside template</div> <div>This is div inside template</div>
<div>This is another div inside template</div> <div>This is another div inside template</div>
</template> </template>
</template> </template>
</body> </body>
</html> </html>

View file

@ -1,56 +1,56 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html> <html>
<head> <head>
<title>Creating and deleting captions</title> <title>Creating and deleting captions</title>
<link rel="author" title="Erika Navara" href="mailto:edoyle@microsoft.com"> <link rel="author" title="Erika Navara" href="mailto:edoyle@microsoft.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-table-element" /> <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-table-element" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-table-createcaption" /> <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-table-createcaption" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-table-deletecaption" /> <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-table-deletecaption" />
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
</head> </head>
<body> <body>
<div id="log"></div> <div id="log"></div>
<table id="table1" style="display:none"> <table id="table1" style="display:none">
<caption id="caption1">caption</caption> <caption id="caption1">caption</caption>
<tr> <tr>
<td>cell</td> <td>cell</td>
<td>cell</td> <td>cell</td>
</tr> </tr>
</table> </table>
<table id="table2" style="display:none"> <table id="table2" style="display:none">
<tr> <tr>
<td>cell</td> <td>cell</td>
<td>cell</td> <td>cell</td>
</tr> </tr>
</table> </table>
<table id="table3" style="display:none"> <table id="table3" style="display:none">
<caption id="caption3">caption 3</caption> <caption id="caption3">caption 3</caption>
<tr> <tr>
<td>cell</td> <td>cell</td>
<td>cell</td> <td>cell</td>
</tr> </tr>
</table> </table>
<script> <script>
test(function () { test(function () {
var table1 = document.getElementById('table1'); var table1 = document.getElementById('table1');
var testCaption = table1.createCaption(); var testCaption = table1.createCaption();
var table1FirstCaption = table1.caption; var table1FirstCaption = table1.caption;
assert_equals(testCaption, table1FirstCaption); assert_equals(testCaption, table1FirstCaption);
}, "createCaption method returns the first caption element child of the table") }, "createCaption method returns the first caption element child of the table")
test(function () { test(function () {
var table2 = document.getElementById('table2'); var table2 = document.getElementById('table2');
var test2Caption = table2.createCaption(); var test2Caption = table2.createCaption();
var table2FirstNode = table2.firstChild; var table2FirstNode = table2.firstChild;
assert_true(test2Caption instanceof HTMLTableCaptionElement); assert_true(test2Caption instanceof HTMLTableCaptionElement);
assert_equals(table2FirstNode, test2Caption); assert_equals(table2FirstNode, test2Caption);
}, "createCaption method creates a new caption and inserts it as the first node of the table element") }, "createCaption method creates a new caption and inserts it as the first node of the table element")
test(function () { test(function () {
var table3 = document.getElementById('table3'); var table3 = document.getElementById('table3');
assert_equals(table3.caption.textContent, "caption 3"); assert_equals(table3.caption.textContent, "caption 3");
table3.deleteCaption(); table3.deleteCaption();
assert_equals(table3.caption, null); assert_equals(table3.caption, null);
}, "deleteCaption method removes the first caption element child of the table element") }, "deleteCaption method removes the first caption element child of the table element")
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,32 +1,32 @@
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<meta charset=utf-8> <meta charset=utf-8>
<title>HTML time element API</title> <title>HTML time element API</title>
<style> <style>
#time { visibility: hidden; } #time { visibility: hidden; }
</style> </style>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-time-element"> <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-time-element">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
</head> </head>
<body> <body>
<div id="log"></div> <div id="log"></div>
<!-- intentionally nested to test parsing rules --> <!-- intentionally nested to test parsing rules -->
<p id="time"><time pubdate datetime="2000-02-01T03:04:05Z">Dummy text <time>2001-06-07T<time>08:09<time></time></time>Z</time></time></p> <p id="time"><time pubdate datetime="2000-02-01T03:04:05Z">Dummy text <time>2001-06-07T<time>08:09<time></time></time>Z</time></time></p>
<script type="text/javascript"> <script type="text/javascript">
function makeTime(dateTime,contents,dateTimeProp) { function makeTime(dateTime,contents,dateTimeProp) {
var timeEl = document.createElement('time'); var timeEl = document.createElement('time');
if( dateTime ) { if( dateTime ) {
timeEl.setAttribute('datetime',dateTime); timeEl.setAttribute('datetime',dateTime);
} }
if( contents ) { if( contents ) {
timeEl.innerHTML = contents; timeEl.innerHTML = contents;
} }
if( dateTimeProp ) { if( dateTimeProp ) {
timeEl.dateTime = dateTimeProp; timeEl.dateTime = dateTimeProp;
} }
return timeEl; return timeEl;
} }
var timep = document.getElementById('time'); var timep = document.getElementById('time');
@ -34,35 +34,35 @@ var times = timep.getElementsByTagName('time');
//TIME elements //TIME elements
test(function () { test(function () {
assert_equals( times.length, 4 ); assert_equals( times.length, 4 );
}, 'HTML parsing should locate 4 time elements in this document'); }, 'HTML parsing should locate 4 time elements in this document');
test(function () { test(function () {
assert_true( !!window.HTMLTimeElement ); assert_true( !!window.HTMLTimeElement );
}, 'HTMLTimeElement should be exposed for prototyping'); }, 'HTMLTimeElement should be exposed for prototyping');
test(function () { test(function () {
assert_true( makeTime() instanceof window.HTMLTimeElement, 'createElement variant' ); assert_true( makeTime() instanceof window.HTMLTimeElement, 'createElement variant' );
assert_true( times[0] instanceof window.HTMLTimeElement, 'HTML parsing variant' ); assert_true( times[0] instanceof window.HTMLTimeElement, 'HTML parsing variant' );
}, 'the time elements should be instanceof HTMLTimeElement'); }, 'the time elements should be instanceof HTMLTimeElement');
//dateTime //dateTime
test(function () { test(function () {
assert_equals( makeTime('2000-02-01T03:04:05Z','2001-02-01T03:04:05Z').dateTime, '2000-02-01T03:04:05Z' ); assert_equals( makeTime('2000-02-01T03:04:05Z','2001-02-01T03:04:05Z').dateTime, '2000-02-01T03:04:05Z' );
}, 'the datetime attribute should be reflected by the .dateTime property'); }, 'the datetime attribute should be reflected by the .dateTime property');
test(function () { test(function () {
assert_equals( typeof makeTime().dateTime, 'string', 'typeof test' ); assert_equals( typeof makeTime().dateTime, 'string', 'typeof test' );
assert_equals( makeTime().dateTime, '', 'value test' ); assert_equals( makeTime().dateTime, '', 'value test' );
}, 'the dateTime IDL property should default to an empty string'); }, 'the dateTime IDL property should default to an empty string');
test(function () { test(function () {
assert_equals( makeTime(false,false,'2000-02-01T03:04:05Z').dateTime, '2000-02-01T03:04:05Z' ); assert_equals( makeTime(false,false,'2000-02-01T03:04:05Z').dateTime, '2000-02-01T03:04:05Z' );
}, 'the dateTime property should be read/write'); }, 'the dateTime property should be read/write');
test(function () { test(function () {
assert_equals( makeTime('go fish').dateTime, 'go fish' ); assert_equals( makeTime('go fish').dateTime, 'go fish' );
}, 'the datetime attribute should be reflected by the .dateTime property even if it is invalid'); }, 'the datetime attribute should be reflected by the .dateTime property even if it is invalid');
test(function () { test(function () {
assert_equals( makeTime(false,'2000-02-01T03:04:05Z').dateTime, '' ); assert_equals( makeTime(false,'2000-02-01T03:04:05Z').dateTime, '' );
}, 'the datetime attribute should not reflect the textContent'); }, 'the datetime attribute should not reflect the textContent');
</script> </script>
</body> </body>
</html> </html>

View file

@ -21,77 +21,77 @@ test(function () {
/* Happy path */ /* Happy path */
test(function () { test(function () {
navigator.registerContentHandler('text/x-unknown-type', location.href + '/%s', 'foo'); navigator.registerContentHandler('text/x-unknown-type', location.href + '/%s', 'foo');
}, 'a handler with valid arguments should work'); }, 'a handler with valid arguments should work');
/* URL argument */ /* URL argument */
test(function () { test(function () {
navigator.registerContentHandler('text/x-unknown-type', '%s', 'foo'); navigator.registerContentHandler('text/x-unknown-type', '%s', 'foo');
}, 'a relative URL should work'); }, 'a relative URL should work');
test(function () { test(function () {
navigator.registerContentHandler('text/x-unknown-type', location.href + '#%s', 'foo'); navigator.registerContentHandler('text/x-unknown-type', location.href + '#%s', 'foo');
}, 'a URL with a fragment identifier should work'); }, 'a URL with a fragment identifier should work');
test(function () { test(function () {
navigator.registerContentHandler('text/x-unknown-type', location.href + '?foo=%s', 'foo'); navigator.registerContentHandler('text/x-unknown-type', location.href + '?foo=%s', 'foo');
}, 'a URL with a query string should work'); }, 'a URL with a query string should work');
test(function () { test(function () {
navigator.registerContentHandler('text/x-unknown-type', location.href + '?foo=%s&bar', 'foo'); navigator.registerContentHandler('text/x-unknown-type', location.href + '?foo=%s&bar', 'foo');
}, 'a URL with a multi-argument query string should work'); }, 'a URL with a multi-argument query string should work');
test(function () { test(function () {
navigator.registerContentHandler('text/x-unknown-type', location.href + '/%s/bar/baz/', 'foo'); navigator.registerContentHandler('text/x-unknown-type', location.href + '/%s/bar/baz/', 'foo');
}, 'a URL with the passed string as a directory name should work'); }, 'a URL with the passed string as a directory name should work');
test(function () { test(function () {
navigator.registerContentHandler('text/x-unknown-type', location.href + '/%s/bar/baz/?foo=1337&bar#baz', 'foo'); navigator.registerContentHandler('text/x-unknown-type', location.href + '/%s/bar/baz/?foo=1337&bar#baz', 'foo');
}, 'a URL with the passed string as a directory name followed by a query string and fragment identifier should work'); }, 'a URL with the passed string as a directory name followed by a query string and fragment identifier should work');
test(function () { test(function () {
navigator.registerContentHandler('text/x-unknown-type', location.href + '/%s/foo/%s/', 'foo'); navigator.registerContentHandler('text/x-unknown-type', location.href + '/%s/foo/%s/', 'foo');
}, 'a URL with the passed string included twice should work'); }, 'a URL with the passed string included twice should work');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', '', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', '', 'foo') } );
}, 'an empty url argument should throw SYNTAX_ERR'); }, 'an empty url argument should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'http://%s.com', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'http://%s.com', 'foo') } );
}, '%s instead of domain name should throw SYNTAX_ERR'); }, '%s instead of domain name should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'http://%s.example.com', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'http://%s.example.com', 'foo') } );
}, '%s instead of subdomain name should throw syntax_err'); }, '%s instead of subdomain name should throw syntax_err');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', location.href + '', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', location.href + '', 'foo') } );
}, 'a url argument without %s should throw SYNTAX_ERR'); }, 'a url argument without %s should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'http://example.com', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'http://example.com', 'foo') } );
}, 'a url argument pointing to a different domain name, without %s should throw SYNTAX_ERR'); }, 'a url argument pointing to a different domain name, without %s should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', location.href + '/%', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', location.href + '/%', 'foo') } );
}, 'a url argument without %s (but with %) should throw SYNTAX_ERR'); }, 'a url argument without %s (but with %) should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', location.href + '/%a', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', location.href + '/%a', 'foo') } );
}, 'a url argument without %s (but with %a) should throw SYNTAX_ERR'); }, 'a url argument without %s (but with %a) should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SECURITY_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'http://example.com/%s', 'foo') } ); assert_throws('SECURITY_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'http://example.com/%s', 'foo') } );
}, 'a url argument pointing to a different domain name should throw SECURITY_ERR'); }, 'a url argument pointing to a different domain name should throw SECURITY_ERR');
test(function () { test(function () {
assert_throws('SECURITY_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'https://example.com/%s', 'foo') } ); assert_throws('SECURITY_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'https://example.com/%s', 'foo') } );
}, 'a url argument pointing to a different domain name should throw SECURITY_ERR (2)'); }, 'a url argument pointing to a different domain name should throw SECURITY_ERR (2)');
test(function () { test(function () {
assert_throws('SECURITY_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'http://foobar.example.com/%s', 'foo') } ); assert_throws('SECURITY_ERR', function () { navigator.registerContentHandler('text/x-unknown-type', 'http://foobar.example.com/%s', 'foo') } );
}, 'a url argument pointing to a different domain name should throw SECURITY_ERR (3)'); }, 'a url argument pointing to a different domain name should throw SECURITY_ERR (3)');
/* Content type argument */ /* Content type argument */
@ -109,9 +109,9 @@ var blacklist = new Array(
for (var bi=0, bl=blacklist.length; bi<bl; ++bi){ for (var bi=0, bl=blacklist.length; bi<bl; ++bi){
test(function () { test(function () {
assert_throws('SECURITY_ERR', function () { navigator.registerContentHandler(blacklist[bi], location.href + '/%s', 'foo') } ); assert_throws('SECURITY_ERR', function () { navigator.registerContentHandler(blacklist[bi], location.href + '/%s', 'foo') } );
}, 'attempting to override the ' + blacklist[bi] + ' MIME type should throw SECURITY_ERR'); }, 'attempting to override the ' + blacklist[bi] + ' MIME type should throw SECURITY_ERR');
} }
@ -124,9 +124,9 @@ var whitelist = new Array('application/atom+xml', /* For feeds. */
for (var wi=0, wl=whitelist.length; wi<wl; ++wi){ for (var wi=0, wl=whitelist.length; wi<wl; ++wi){
test(function () { test(function () {
navigator.registerContentHandler(whitelist[wi], location.href + '/%s', 'foo'); navigator.registerContentHandler(whitelist[wi], location.href + '/%s', 'foo');
}, 'overriding the ' + whitelist[wi] + ' MIME type should work'); }, 'overriding the ' + whitelist[wi] + ' MIME type should work');
} }

View file

@ -20,163 +20,163 @@ test(function () {
}, 'the registerProtocolHandler method should exist on the navigator object'); }, 'the registerProtocolHandler method should exist on the navigator object');
test(function () { test(function () {
navigator.registerProtocolHandler('tel', location.href + '/%s', 'foo'); navigator.registerProtocolHandler('tel', location.href + '/%s', 'foo');
}, 'a handler with valid arguments should work'); }, 'a handler with valid arguments should work');
/* URL argument */ /* URL argument */
test(function () { test(function () {
navigator.registerProtocolHandler('tel', '%s', 'foo'); navigator.registerProtocolHandler('tel', '%s', 'foo');
}, 'a relative URL should work'); }, 'a relative URL should work');
test(function () { test(function () {
navigator.registerProtocolHandler('tel', location.href + '#%s', 'foo'); navigator.registerProtocolHandler('tel', location.href + '#%s', 'foo');
}, 'a URL with a fragment identifier should work'); }, 'a URL with a fragment identifier should work');
test(function () { test(function () {
navigator.registerProtocolHandler('tel', location.href + '?foo=%s', 'foo'); navigator.registerProtocolHandler('tel', location.href + '?foo=%s', 'foo');
}, 'a URL with a query string should work'); }, 'a URL with a query string should work');
test(function () { test(function () {
navigator.registerProtocolHandler('tel', location.href + '?foo=%s&bar', 'foo'); navigator.registerProtocolHandler('tel', location.href + '?foo=%s&bar', 'foo');
}, 'a URL with a multi-argument query string should work'); }, 'a URL with a multi-argument query string should work');
test(function () { test(function () {
navigator.registerProtocolHandler('tel', location.href + '/%s/bar/baz/', 'foo'); navigator.registerProtocolHandler('tel', location.href + '/%s/bar/baz/', 'foo');
}, 'a URL with the passed string as a directory name should work'); }, 'a URL with the passed string as a directory name should work');
test(function () { test(function () {
navigator.registerProtocolHandler('tel', location.href + '/%s/bar/baz/?foo=1337&bar#baz', 'foo'); navigator.registerProtocolHandler('tel', location.href + '/%s/bar/baz/?foo=1337&bar#baz', 'foo');
}, 'a URL with the passed string as a directory name followed by a query string and fragment identifier should work'); }, 'a URL with the passed string as a directory name followed by a query string and fragment identifier should work');
test(function () { test(function () {
navigator.registerProtocolHandler('tel', location.href + '/%s/foo/%s/', 'foo'); navigator.registerProtocolHandler('tel', location.href + '/%s/foo/%s/', 'foo');
}, 'a URL with the passed string included twice should work'); }, 'a URL with the passed string included twice should work');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', '', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', '', 'foo') } );
}, 'an empty url argument should throw SYNTAX_ERR'); }, 'an empty url argument should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', 'http://%s.com', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', 'http://%s.com', 'foo') } );
}, '%s instead of domain name should throw SYNTAX_ERR'); }, '%s instead of domain name should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', 'http://%s.example.com', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', 'http://%s.example.com', 'foo') } );
}, '%s instead of subdomain name should throw SYNTAX_ERR'); }, '%s instead of subdomain name should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', location.href + '', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', location.href + '', 'foo') } );
}, 'a url argument without %s should throw SYNTAX_ERR'); }, 'a url argument without %s should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', 'http://example.com', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', 'http://example.com', 'foo') } );
}, 'a url argument pointing to a different domain name, without %s should throw SYNTAX_ERR'); }, 'a url argument pointing to a different domain name, without %s should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', location.href + '/%', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', location.href + '/%', 'foo') } );
}, 'a url argument without %s (but with %) should throw SYNTAX_ERR'); }, 'a url argument without %s (but with %) should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', location.href + '/%a', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto', location.href + '/%a', 'foo') } );
}, 'a url argument without %s (but with %a) should throw SYNTAX_ERR'); }, 'a url argument without %s (but with %a) should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler('mailto', 'http://example.com/%s', 'foo') } ); assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler('mailto', 'http://example.com/%s', 'foo') } );
}, 'a url argument pointing to a different domain name should throw SECURITY_ERR'); }, 'a url argument pointing to a different domain name should throw SECURITY_ERR');
test(function () { test(function () {
assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler('mailto', 'https://example.com/%s', 'foo') } ); assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler('mailto', 'https://example.com/%s', 'foo') } );
}, 'a url argument pointing to a different domain name should throw SECURITY_ERR (2)'); }, 'a url argument pointing to a different domain name should throw SECURITY_ERR (2)');
test(function () { test(function () {
assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler('mailto', 'http://foobar.example.com/%s', 'foo') } ); assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler('mailto', 'http://foobar.example.com/%s', 'foo') } );
}, 'a url argument pointing to a different domain name should throw SECURITY_ERR (3)'); }, 'a url argument pointing to a different domain name should throw SECURITY_ERR (3)');
test(function () { test(function () {
assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler('mailto', 'mailto:%s@example.com', 'foo') } ); assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler('mailto', 'mailto:%s@example.com', 'foo') } );
}, 'looping handlers should throw SECURITY_ERR'); }, 'looping handlers should throw SECURITY_ERR');
test(function () { test(function () {
assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler('sms', 'tel:%s', 'foo') } ); assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler('sms', 'tel:%s', 'foo') } );
}, 'a url argument pointing to a non-http[s] scheme should throw SECURITY_ERR due to not being of the same origin'); }, 'a url argument pointing to a non-http[s] scheme should throw SECURITY_ERR due to not being of the same origin');
/* Protocol argument */ /* Protocol argument */
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('unrecognized', location.href + '/%a', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('unrecognized', location.href + '/%a', 'foo') } );
}, 'a protocol argument containing an unrecognized scheme should throw SECURITY_ERR'); /* This is a whitelist, not a blacklist. */ }, 'a protocol argument containing an unrecognized scheme should throw SECURITY_ERR'); /* This is a whitelist, not a blacklist. */
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto:', location.href + '/%a', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto:', location.href + '/%a', 'foo') } );
}, 'a protocol argument containing : should throw SYNTAX_ERR'); }, 'a protocol argument containing : should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto://', location.href + '/%a', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto://', location.href + '/%a', 'foo') } );
}, 'a protocol argument containing :// should throw SYNTAX_ERR'); }, 'a protocol argument containing :// should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('http://', location.href + '/%a', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('http://', location.href + '/%a', 'foo') } );
}, 'a protocol argument containing http:// should throw SYNTAX_ERR'); }, 'a protocol argument containing http:// should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto' + String.fromCharCode(0), location.href + '/%a', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto' + String.fromCharCode(0), location.href + '/%a', 'foo') } );
}, 'a protocol argument containing a null character should throw SYNTAX_ERR'); }, 'a protocol argument containing a null character should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailtoo' + String.fromCharCode(8), location.href + '/%a', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailtoo' + String.fromCharCode(8), location.href + '/%a', 'foo') } );
}, 'a protocol argument containing a backspace character should throw SYNTAX_ERR'); }, 'a protocol argument containing a backspace character should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto' + String.fromCharCode(10), location.href + '/%a', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mailto' + String.fromCharCode(10), location.href + '/%a', 'foo') } );
}, 'a protocol argument containing a LF character should throw SYNTAX_ERR'); }, 'a protocol argument containing a LF character should throw SYNTAX_ERR');
test(function () { test(function () {
assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mаilto', location.href + '/%a', 'foo') } ); assert_throws('SYNTAX_ERR', function () { navigator.registerProtocolHandler('mаilto', location.href + '/%a', 'foo') } );
}, 'a protocol argument containing non-alphanumeric characters (like a cyrillic “а”) should throw SYNTAX_ERR'); }, 'a protocol argument containing non-alphanumeric characters (like a cyrillic “а”) should throw SYNTAX_ERR');
test(function () { test(function () {
navigator.registerProtocolHandler('TEL', location.href + '/%s', 'foo'); navigator.registerProtocolHandler('TEL', location.href + '/%s', 'foo');
}, 'a protocol argument of “TEL” should be equivalent to “tel”'); }, 'a protocol argument of “TEL” should be equivalent to “tel”');
test(function () { test(function () {
navigator.registerProtocolHandler('teL', location.href + '/%s', 'foo'); navigator.registerProtocolHandler('teL', location.href + '/%s', 'foo');
}, 'a protocol argument of “teL” should be equivalent to “tel”'); }, 'a protocol argument of “teL” should be equivalent to “tel”');
/* Overriding any of the following protocols must never be allowed. That would /* Overriding any of the following protocols must never be allowed. That would
* break the browser. */ * break the browser. */
var blacklist = new Array( var blacklist = new Array(
'about', 'about',
'attachment', 'attachment',
'blob', 'blob',
'chrome', 'chrome',
'cid', 'cid',
'data', 'data',
'file', 'file',
'ftp', 'ftp',
'http', 'http',
'https', 'https',
'javascript', 'javascript',
'livescript', 'livescript',
'mid', 'mid',
'mocha', 'mocha',
'opera', 'opera',
'operamail', 'operamail',
'res', 'res',
'resource', 'resource',
'shttp', 'shttp',
'tcl', 'tcl',
'vbscript', 'vbscript',
'view-source', 'view-source',
'ws', 'ws',
'wss', 'wss',
'wyciwyg'); 'wyciwyg');
for ( var bi=0, bl=blacklist.length; bi<bl; ++bi ){ for ( var bi=0, bl=blacklist.length; bi<bl; ++bi ){
test(function () { test(function () {
assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler(blacklist[bi], location.href + '/%s', 'foo') } ); assert_throws('SECURITY_ERR', function () { navigator.registerProtocolHandler(blacklist[bi], location.href + '/%s', 'foo') } );
}, 'attempting to override the ' + blacklist[bi] + ' protocol should throw SECURITY_ERR'); }, 'attempting to override the ' + blacklist[bi] + ' protocol should throw SECURITY_ERR');
} }
@ -184,28 +184,28 @@ for ( var bi=0, bl=blacklist.length; bi<bl; ++bi ){
* We're just testing that the call goes through here. Whether or not they * We're just testing that the call goes through here. Whether or not they
* actually work as handlers is covered by the interactive tests. */ * actually work as handlers is covered by the interactive tests. */
var whitelist = new Array( var whitelist = new Array(
'geo', 'geo',
'im', 'im',
'irc', 'irc',
'ircs', 'ircs',
'mailto', 'mailto',
'mms', 'mms',
'news', 'news',
'nntp', 'nntp',
'sms', 'sms',
'smsto', 'smsto',
'tel', 'tel',
'urn', 'urn',
'webcal', 'webcal',
'wtai', 'wtai',
'xmpp'); 'xmpp');
for ( var wi=0, wl=whitelist.length; wi<wl; ++wi ){ for ( var wi=0, wl=whitelist.length; wi<wl; ++wi ){
test(function () { test(function () {
navigator.registerProtocolHandler(whitelist[wi], location.href + '/%s', 'foo'); navigator.registerProtocolHandler(whitelist[wi], location.href + '/%s', 'foo');
assert_true(true); assert_true(true);
}, 'overriding the ' + whitelist[wi] + ' protocol should work'); }, 'overriding the ' + whitelist[wi] + ' protocol should work');
} }
</script> </script>

View file

@ -15,9 +15,7 @@ INDENT TABS: custom-elements/*
INDENT TABS: DOMEvents/* INDENT TABS: DOMEvents/*
INDENT TABS: eventsource/* INDENT TABS: eventsource/*
INDENT TABS: html/editing/dnd/* INDENT TABS: html/editing/dnd/*
INDENT TABS: html/semantics/*
INDENT TABS: html/syntax/* INDENT TABS: html/syntax/*
INDENT TABS: html/webappapis/*
INDENT TABS: media-source/* INDENT TABS: media-source/*
INDENT TABS: old-tests/* INDENT TABS: old-tests/*
INDENT TABS: pointerlock/* INDENT TABS: pointerlock/*
@ -89,6 +87,7 @@ PRINT STATEMENT:*/tools/*
CR AT EOL:WebIDL/valid/idl/documentation-dos.widl CR AT EOL:WebIDL/valid/idl/documentation-dos.widl
CR AT EOL:cors/resources/cors-headers.asis CR AT EOL:cors/resources/cors-headers.asis
CR AT EOL:html/semantics/embedded-content/the-canvas-element/size.attributes.parse.whitespace.html CR AT EOL:html/semantics/embedded-content/the-canvas-element/size.attributes.parse.whitespace.html
INDENT TABS:html/semantics/embedded-content/the-canvas-element/size.attributes.parse.whitespace.html
CR AT EOL:webvtt/webvtt-file-format-parsing/webvtt-file-parsing/support/newlines.vtt CR AT EOL:webvtt/webvtt-file-format-parsing/webvtt-file-parsing/support/newlines.vtt
PARSE-FAILED:dom/nodes/Document-createElement-namespace-tests/empty.svg PARSE-FAILED:dom/nodes/Document-createElement-namespace-tests/empty.svg
PARSE-FAILED:dom/nodes/Document-createElement-namespace-tests/empty.xhtml PARSE-FAILED:dom/nodes/Document-createElement-namespace-tests/empty.xhtml

View file

@ -97,5 +97,5 @@ function mediaSourceConfigChangeTest(directory, idA, idB, description)
}); });
}); });
}); });
}, description, { timeout: 10000 } ); }, description);
}; };

View file

@ -211,7 +211,7 @@
test.done(); test.done();
}); });
}); });
}, 'Test setting same duration multiple times does not fire duplicate durationchange', {timeout: 2500}); }, 'Test setting same duration multiple times does not fire duplicate durationchange');
</script> </script>
</body> </body>
</html> </html>

View file

@ -65,7 +65,7 @@
assert_greater_than(timeUpdateCount, 2, "timeUpdateCount"); assert_greater_than(timeUpdateCount, 2, "timeUpdateCount");
test.done(); test.done();
}); });
}, "Test HTMLVideoElement.getVideoPlaybackQuality() with MediaSource API", {timeout: 5000}); }, "Test HTMLVideoElement.getVideoPlaybackQuality() with MediaSource API");
</script> </script>
</body> </body>
</html> </html>

View file

@ -38,7 +38,7 @@
mediaSource.endOfStream(); mediaSource.endOfStream();
mediaElement.play(); mediaElement.play();
}); });
}, "Test normal playback case with MediaSource API", {timeout: 5000}); }, "Test normal playback case with MediaSource API");
</script> </script>
</body> </body>
</html> </html>

View file

@ -63,7 +63,7 @@
test.done(); test.done();
}); });
}, 'Test seeking to a new location before transitioning beyond HAVE_METADATA.', {timeout: 10000} ); }, 'Test seeking to a new location before transitioning beyond HAVE_METADATA.');
mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
{ {
@ -136,7 +136,7 @@
assert_greater_than(mediaElement.readyState, mediaElement.HAVE_CURRENT_DATA, 'Greater than HAVE_CURRENT_DATA'); assert_greater_than(mediaElement.readyState, mediaElement.HAVE_CURRENT_DATA, 'Greater than HAVE_CURRENT_DATA');
test.done(); test.done();
}); });
}, 'Test seeking to a new location during a pending seek.', {timeout: 10000} ); }, 'Test seeking to a new location during a pending seek.');
</script> </script>
</body> </body>
</html> </html>

View file

@ -1,6 +1,4 @@
(function(window) { (function(window) {
setup({ timeout: 12000 });
var SEGMENT_INFO_LIST = [ var SEGMENT_INFO_LIST = [
{ {
url: 'mp4/test.mp4', url: 'mp4/test.mp4',

View file

@ -1,18 +1,18 @@
<!DOCTYPE html> <!DOCTYPE html>
<html><head> <html><head>
<title> scheduler: removing async attribute at runtime</title> <title> scheduler: removing async attribute at runtime</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="testlib/testlib.js"></script> <script src="testlib/testlib.js"></script>
</head> </head>
<body> <body>
<div id="test"></div> <div id="test"></div>
<div id="log">FAILED (This TC requires JavaScript enabled)</div> <div id="log">FAILED (This TC requires JavaScript enabled)</div>
<script id="async-script" async src="scripts/include-2.js?pipe=trickle(d1)"></script> <script id="async-script" async src="scripts/include-2.js?pipe=trickle(d2)"></script>
<script> <script>
var t = async_test(); var t = async_test();
t.step(function() { t.step(function() {
@ -27,6 +27,6 @@
assert_array_equals(eventOrder, ["external script #1", "external script #2"]); assert_array_equals(eventOrder, ["external script #1", "external script #2"]);
t.done(); t.done();
}), false); }), false);
</script> </script>
</body></html> </body></html>

View file

@ -0,0 +1,9 @@
<!DOCTYPE html>
<head>
<title>Referrer-Policy Web Platform Tests - README</title>
</head>
<body>
<p>
TODO(burnik): Instructions on how to write tests for Referrer-Policy.
</p>
</body>

View file

@ -0,0 +1,28 @@
// NOTE: This method only strips the fragment and is not in accordance to the
// recommended draft specification:
// https://w3c.github.io/webappsec/specs/referrer-policy/#null
// TODO(burnik): Implement this helper as defined by spec once added scenarios
// for URLs containing username/password/etc.
function stripUrlForUseAsReferrer(url) {
return url.replace(/#.*$/, "");
}
function parseUrlQueryString(queryString) {
var queries = queryString.replace(/^\?/, "").split("&");
var params = {};
for (var i in queries) {
var kvp = queries[i].split("=");
params[kvp[0]] = kvp[1];
}
return params;
};
function appendIframeToBody(url) {
var iframe = document.createElement("iframe");
iframe.src = url;
document.body.appendChild(iframe);
return iframe;
}

View file

@ -0,0 +1,159 @@
<!DOCTYPE html>
<html>
<head>
<title>Check that sub-resource gets the referrer URL when no explicit
Referrer Policy is set.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- Common global functions for referrer-policy tests. -->
<script src="../generic/common.js"></script>
</head>
<body>
<h1>Check that sub-resource gets the referrer URL when no explicit Referrer
Policy is set.</h1>
<p>This page loads sub-resources (iframes) and waits for messages containing
referrer URLs from children.</p>
<script>
var documentUrl = document.location.toString();
// Referrer policy can also be defined via meta tag of parent.
// TODO(burnik): For now we use the DOM element itself as we expect it not
// to be explicitly defined on the page. We should use the content
// attribute value instead.
var documentMetaReferrer = document.querySelector("meta[name=referrer]");
// The referrer URL should be this document's URL adjusted according to
// this section:
// https://w3c.github.io/webappsec/specs/referrer-policy/#strip-url
var expectedReferrerUrl = stripUrlForUseAsReferrer(documentUrl);
// Path to the sub-resource page which reports back it's own context.
var subresourceUrlPath = "/referrer-policy/no-referrer-policy" +
"/no-referrer-policy.subresource.py";
// Define all the test definitions here to create correspoding test
// arrangements. Each test arrangement will have it's own iframe and ID
// passed by URL. The ID should be unique as it identifies the message
// coming back from the iframe and matches the corressponding test to be
// run.
var scenarios = [
{
id: "same-origin",
url: location.protocol + "//" + location.hostname + ":" +
location.port + subresourceUrlPath,
metaReferrer: documentMetaReferrer,
expectedReferrerUrl: expectedReferrerUrl,
description: "Refrerer URL is passed to sub-resource (iframe) of " +
"same-origin."
},
{
id: "cross-origin",
url: location.protocol + "//www1." + location.hostname + ":" +
location.port + subresourceUrlPath,
metaReferrer: documentMetaReferrer,
expectedReferrerUrl: expectedReferrerUrl,
description: "Refrerer URL is passed to sub-resource (iframe) of " +
"cross-origin."
}
];
//////////////////////////////////////////////////////////////////////////
// Rest of the script arranges and runs all the tests defined above.
//////////////////////////////////////////////////////////////////////////
// Creates a test arrangement from a test scenario.
function arrangeScenario(scenario) {
var test = async_test(scenario.description);
var subresourceUrl = scenario.url + "?id=" + scenario.id;
var testArrangement = {
scenario:scenario,
test:test,
subresourceUrl:subresourceUrl
};
return testArrangement;
}
// Asserts the values for an iframe response message and matched test
// arrangement.
function assertScenario(message, testArrangement) {
// Defense: Making sure the message and test arrangement are up to date.
testArrangement.test.step(function() {
assert_equals(Object.keys(message).length, 4);
assert_own_property(message, "id");
assert_own_property(message, "location");
assert_own_property(message, "referrer");
assert_own_property(message, "headers");
assert_own_property(message.headers, "referer");
assert_equals(Object.keys(testArrangement).length, 3);
assert_own_property(testArrangement, "scenario");
assert_own_property(testArrangement, "test");
assert_own_property(testArrangement, "subresourceUrl");
assert_equals(Object.keys(testArrangement.scenario).length, 5);
assert_own_property(testArrangement.scenario, "id");
assert_own_property(testArrangement.scenario, "url");
assert_own_property(testArrangement.scenario, "metaReferrer");
assert_own_property(testArrangement.scenario, "expectedReferrerUrl");
assert_own_property(testArrangement.scenario, "description");
}, "Running a valid test scenario.");
testArrangement.test.step(function() {
// TODO(burnik): This check should be specified by the scenario
// itself. For now we only expect that there is no CSP so neither is
// the referrer policy explicitly defined via HTTP headers.
assert_not_exists(message.headers, "content-security-policy",
"No referrer policy is set.");
// The meta defined refferer should also not exist.
assert_equals(testArrangement.scenario.metaReferrer, null);
}, "No referrer policy is explicity defined via HTTP headers or meta.")
testArrangement.test.step(function() {
// Sanity check - location of iframe matches reported location.
assert_equals(message.location, testArrangement.subresourceUrl,
"Child reported location.");
// Child reports the referrer URL available from DOM.
assert_equals(message.referrer,
testArrangement.scenario.expectedReferrerUrl,
"Child reported referrer.");
// Also check the request headers reported from the server.
assert_equals(message.headers.referer,
testArrangement.scenario.expectedReferrerUrl,
"Child reported referrer (from server).");
}, "Referrer URL is passed to the sub-resource (iframe).");
testArrangement.test.done();
}
// Using a map to easily find and run the test corresponding to the
// received message ID (iframe).
var testArrangementMap = {};
// With this handler we receive all the messages from the iframes.
// We identify the source and appropriate test arrangement to be run via
// the provided message ID.
window.addEventListener("message", function (event) {
var childMessage = event.data;
var testArrangement = testArrangementMap[childMessage.id];
// Run the test for this sub-resource.
assertScenario(childMessage, testArrangement);
});
// Map all test arrangements by ID and append iframes.
for (var i in scenarios) {
var testArrangement = arrangeScenario(scenarios[i]);
testArrangementMap[scenarios[i].id] = testArrangement;
appendIframeToBody(testArrangement.subresourceUrl);
}
</script>
<div id="log"></div>
</body>
</html>

View file

@ -0,0 +1,15 @@
import os, json
def main(request, response):
script_directory = os.path.dirname(os.path.abspath(__file__))
template_basename = "no-referrer-policy.subresource.template.html"
template_filename = os.path.join(script_directory, template_basename);
with open(template_filename) as f:
template = f.read()
headers_as_json = json.dumps(request.headers)
exported_headers = "var SERVER_REQUEST_HEADERS = " + headers_as_json + ";"
rendered_html = template % {"headers": headers_as_json}
return response.headers, rendered_html

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<title>This page reports back it's request details the parent frame</title>
<!-- Common global functions for referrer-policy tests. -->
<script src="../generic/common.js"></script>
</head>
<body>
<h2>This page reports back it's request details to the parent frame.</h2>
<script>
// Notice: This is filled in from server side.
var SERVER_REQUEST_HEADERS = %(headers)s;
var query = parseUrlQueryString(document.location.search)
// Note: Read the ID from the query section of this page's URL.
// The ID is used to identify the sender of the message in the parent.
var pageInfo = {
id: query.id,
location: document.location.toString(),
referrer: document.referrer,
headers: SERVER_REQUEST_HEADERS
};
// Notify parent frame.
parent.postMessage(pageInfo, "*");
</script>
</body>
</html>

View file

@ -56,6 +56,19 @@ function constValue (cnt) {
return cnt.value; return cnt.value;
} }
function minOverloadLength(overloads) {
if (!overloads.length) {
return 0;
}
return overloads.map(function(attr) {
return attr.arguments ? attr.arguments.filter(function(arg) {
return !arg.optional && !arg.variadic;
}).length : 0;
})
.reduce(function(m, n) { return Math.min(m, n); });
}
/// IdlArray /// /// IdlArray ///
// Entry point // Entry point
self.IdlArray = function() self.IdlArray = function()
@ -754,22 +767,7 @@ IdlInterface.prototype.test_self = function()
var constructors = this.extAttrs var constructors = this.extAttrs
.filter(function(attr) { return attr.name == "Constructor"; }); .filter(function(attr) { return attr.name == "Constructor"; });
var expected_length; var expected_length = minOverloadLength(constructors);
if (!constructors.length) {
// "If the [Constructor] extended attribute, does not appear on
// the interface definition, then the value is 0."
expected_length = 0;
} else {
// "Otherwise, the value is determined as follows: . . .
// "Return the length of the shortest argument list of the
// entries in S."
expected_length = constructors.map(function(attr) {
return attr.arguments ? attr.arguments.filter(function(arg) {
return !arg.optional;
}).length : 0;
})
.reduce(function(m, n) { return Math.min(m, n); });
}
assert_equals(self[this.name].length, expected_length, "wrong value for " + this.name + ".length"); assert_equals(self[this.name].length, expected_length, "wrong value for " + this.name + ".length");
}.bind(this), this.name + " interface object length"); }.bind(this), this.name + " interface object length");
} }
@ -1122,12 +1120,10 @@ IdlInterface.prototype.do_member_operation_asserts = function(memberHolderObject
// ". . . // ". . .
// "Return the length of the shortest argument list of the // "Return the length of the shortest argument list of the
// entries in S." // entries in S."
//
// TODO: Doesn't handle overloading or variadic arguments.
assert_equals(memberHolderObject[member.name].length, assert_equals(memberHolderObject[member.name].length,
member.arguments.filter(function(arg) { minOverloadLength(this.members.filter(function(m) {
return !arg.optional; return m.type == "operation" && m.name == member.name;
}).length, })),
"property has wrong .length"); "property has wrong .length");
// Make some suitable arguments // Make some suitable arguments
@ -1460,13 +1456,12 @@ IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expect
{ {
assert_false(member.name in obj); assert_false(member.name in obj);
} }
var minLength = minOverloadLength(this.members.filter(function(m) {
return m.type == "operation" && m.name == member.name;
}));
var args = []; var args = [];
for (var i = 0; i < member.arguments.length; i++) for (var i = 0; i < minLength; i++) {
{
if (member.arguments[i].optional)
{
break;
}
assert_throws(new TypeError(), function() assert_throws(new TypeError(), function()
{ {
obj[member.name].apply(obj, args); obj[member.name].apply(obj, args);

View file

@ -368,8 +368,20 @@ policies and contribution forms [3].
self.addEventListener("message", self.addEventListener("message",
function(event) { function(event) {
if (event.data.type && event.data.type === "connect") { if (event.data.type && event.data.type === "connect") {
this_obj._add_message_port(event.ports[0]); if (event.ports && event.ports[0]) {
event.ports[0].start(); // If a MessageChannel was passed, then use it to
// send results back to the main window. This
// allows the tests to work even if the browser
// does not fully support MessageEvent.source in
// ServiceWorkers yet.
this_obj._add_message_port(event.ports[0]);
event.ports[0].start();
} else {
// If there is no MessageChannel, then attempt to
// use the MessageEvent.source to send results
// back to the main window.
this_obj._add_message_port(event.source);
}
} }
}); });
@ -1476,15 +1488,24 @@ policies and contribution forms [3].
var message_port; var message_port;
if (is_service_worker(worker)) { if (is_service_worker(worker)) {
// The ServiceWorker's implicit MessagePort is currently not if (window.MessageChannel) {
// reliably accessible from the ServiceWorkerGlobalScope due to // The ServiceWorker's implicit MessagePort is currently not
// Blink setting MessageEvent.source to null for messages sent via // reliably accessible from the ServiceWorkerGlobalScope due to
// ServiceWorker.postMessage(). Until that's resolved, create an // Blink setting MessageEvent.source to null for messages sent
// explicit MessageChannel and pass one end to the worker. // via ServiceWorker.postMessage(). Until that's resolved,
var message_channel = new MessageChannel(); // create an explicit MessageChannel and pass one end to the
message_port = message_channel.port1; // worker.
message_port.start(); var message_channel = new MessageChannel();
worker.postMessage({type: "connect"}, [message_channel.port2]); message_port = message_channel.port1;
message_port.start();
worker.postMessage({type: "connect"}, [message_channel.port2]);
} else {
// If MessageChannel is not available, then try the
// ServiceWorker.postMessage() approach using MessageEvent.source
// on the other end.
message_port = navigator.serviceWorker;
worker.postMessage({type: "connect"});
}
} else if (is_shared_worker(worker)) { } else if (is_shared_worker(worker)) {
message_port = worker.port; message_port = worker.port;
} else { } else {
@ -2335,7 +2356,15 @@ policies and contribution forms [3].
AssertionError.prototype = Object.create(Error.prototype); AssertionError.prototype = Object.create(Error.prototype);
AssertionError.prototype.get_stack = function() { AssertionError.prototype.get_stack = function() {
var lines = new Error().stack.split("\n"); var stack = new Error().stack;
if (!stack) {
try {
throw new Error();
} catch (e) {
stack = e.stack;
}
}
var lines = stack.split("\n");
var rv = []; var rv = [];
var re = /\/resources\/testharness\.js/; var re = /\/resources\/testharness\.js/;
var i = 0; var i = 0;

View file

@ -103,14 +103,6 @@ var vary_entries = [
request: new Request('http://example.com/c'), request: new Request('http://example.com/c'),
response: new Response('', response: new Response('',
{headers: {'Vary': 'Cookies'}}) {headers: {'Vary': 'Cookies'}})
},
{
name: 'vary_wildcard',
request: new Request('http://example.com/c',
{headers: {'Cookies': 'x', 'X-Key': '1'}}),
response: new Response('',
{headers: {'Vary': '*'}})
} }
]; ];
@ -311,7 +303,6 @@ prepopulated_cache_test(vary_entries, function(cache, entries) {
assert_array_equivalent( assert_array_equivalent(
result, result,
[ [
entries.vary_wildcard.response,
entries.vary_cookie_absent.response entries.vary_cookie_absent.response
], ],
'Cache.matchAll should exclude matches if a vary header is ' + 'Cache.matchAll should exclude matches if a vary header is ' +
@ -328,7 +319,6 @@ prepopulated_cache_test(vary_entries, function(cache, entries) {
assert_array_equivalent( assert_array_equivalent(
result, result,
[ [
entries.vary_wildcard.response
], ],
'Cache.matchAll should exclude matches if a vary header is ' + 'Cache.matchAll should exclude matches if a vary header is ' +
'missing in the cached request, but is present in the query ' + 'missing in the cached request, but is present in the query ' +
@ -355,7 +345,6 @@ prepopulated_cache_test(vary_entries, function(cache, entries) {
assert_object_in_array( assert_object_in_array(
result, result,
[ [
entries.vary_wildcard.response,
entries.vary_cookie_absent.response entries.vary_cookie_absent.response
], ],
'Cache.match should honor "Vary" header.'); 'Cache.match should honor "Vary" header.');
@ -372,7 +361,6 @@ prepopulated_cache_test(vary_entries, function(cache, entries) {
entries.vary_cookie_is_cookie.response, entries.vary_cookie_is_cookie.response,
entries.vary_cookie_is_good.response, entries.vary_cookie_is_good.response,
entries.vary_cookie_absent.response, entries.vary_cookie_absent.response,
entries.vary_wildcard.response
], ],
'Cache.matchAll should honor "ignoreVary" parameter.'); 'Cache.matchAll should honor "ignoreVary" parameter.');
}); });

View file

@ -283,12 +283,35 @@ cache_test(function(cache) {
'[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' + '[https://fetch.spec.whatwg.org/#dom-body-bodyused] ' +
'Response.bodyUsed should be initially false.'); 'Response.bodyUsed should be initially false.');
return response.text().then(function() { return response.text().then(function() {
assert_false( assert_true(
response.bodyUsed, response.bodyUsed,
'[https://fetch.spec.whatwg.org/#concept-body-consume-body] ' + '[https://fetch.spec.whatwg.org/#concept-body-consume-body] ' +
'The text() method should not set "body passed" flag.'); 'The text() method should set "body used" flag.');
return cache.put(new Request(test_url), response); return assert_promise_rejects(
}); cache.put(new Request(test_url), response),
new TypeError,
'[https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#cache-put] ' +
'Cache put should reject with TypeError when Response ' +
'body is already used.');
});
}, 'Cache.put with a used response body'); }, 'Cache.put with a used response body');
cache_test(function(cache) {
return assert_promise_rejects(
cache.put(new Request(test_url),
new Response(test_body, { headers: { VARY: '*' }})),
new TypeError(),
'Cache.put should reject VARY:* Responses with a TypeError.');
}, 'Cache.put with a VARY:* Response');
cache_test(function(cache) {
return assert_promise_rejects(
cache.put(new Request(test_url),
new Response(test_body,
{ headers: { VARY: 'Accept-Language,*' }})),
new TypeError(),
'Cache.put should reject Responses with an embedded VARY:* with a ' +
'TypeError.');
}, 'Cache.put with an embedded VARY:* Response');
done(); done();

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>Cache.add and Cache.addAll</title> <title>Cache.add and Cache.addAll</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-add"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-add">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="../../service-workers/resources/test-helpers.js"></script> <script src="../../service-workers/resources/test-helpers.js"></script>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>Cache.delete</title> <title>Cache.delete</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-delete"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-delete">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="../../service-workers/resources/test-helpers.js"></script> <script src="../../service-workers/resources/test-helpers.js"></script>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>CacheStorage.keys</title> <title>CacheStorage.keys</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="../../service-workers/resources/test-helpers.js"></script> <script src="../../service-workers/resources/test-helpers.js"></script>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>CacheStorage.match</title> <title>CacheStorage.match</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage-match"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage-match">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="../../service-workers/resources/test-helpers.js"></script> <script src="../../service-workers/resources/test-helpers.js"></script>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>CacheStorage</title> <title>CacheStorage</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="../../service-workers/resources/test-helpers.js"></script> <script src="../../service-workers/resources/test-helpers.js"></script>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>Cache Storage: Cache.add and Cache.addAll</title> <title>Cache Storage: Cache.add and Cache.addAll</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-add"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-add">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="../resources/testharness-helpers.js"></script> <script src="../resources/testharness-helpers.js"></script>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>Cache Storage: Cache.delete</title> <title>Cache Storage: Cache.delete</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-delete"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-delete">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="../resources/testharness-helpers.js"></script> <script src="../resources/testharness-helpers.js"></script>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>Cache Storage: CacheStorage.keys</title> <title>Cache Storage: CacheStorage.keys</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="../resources/testharness-helpers.js"></script> <script src="../resources/testharness-helpers.js"></script>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>Cache Storage: CacheStorage.match</title> <title>Cache Storage: CacheStorage.match</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage-match"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage-match">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="../resources/testharness-helpers.js"></script> <script src="../resources/testharness-helpers.js"></script>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>Cache Storage: CacheStorage</title> <title>Cache Storage: CacheStorage</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="../resources/testharness-helpers.js"></script> <script src="../resources/testharness-helpers.js"></script>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>Cache Storage: Verify access in sandboxed iframes</title> <title>Cache Storage: Verify access in sandboxed iframes</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="../resources/testharness-helpers.js"></script> <script src="../resources/testharness-helpers.js"></script>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>Cache.add and Cache.addAll</title> <title>Cache.add and Cache.addAll</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-add"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-add">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script> <script>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>Cache.delete</title> <title>Cache.delete</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-delete"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-delete">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script> <script>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>CacheStorage.keys</title> <title>CacheStorage.keys</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script> <script>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>CacheStorage.match</title> <title>CacheStorage.match</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage-match"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage-match">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script> <script>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<title>CacheStorage</title> <title>CacheStorage</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage"> <link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-storage">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script> <script>

View file

@ -1,6 +1,6 @@
<!doctype html> <!doctype html>
<meta charset=utf-8> <meta charset=utf-8>
<title>Web Animations API: AnimationTimeline tests</title> <title>Web Animations API: DocumentTimeline tests</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<div id="log"></div> <div id="log"></div>

View file

@ -1,15 +1,18 @@
<!doctype html> <!doctype html>
<meta charset=utf-8> <meta charset=utf-8>
<title>Web Animations API: AnimationTimeline tests</title> <title>Web Animations API: DocumentTimeline tests</title>
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script> <script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script> <script src="/resources/idlharness.js"></script>
<div id="log"></div> <div id="log"></div>
<script type="text/plain" id="AnimationTimeline-IDL"> <script type="text/plain" id="DocumentTimeline-IDL">
interface AnimationTimeline { interface AnimationTimeline {
readonly attribute double? currentTime; readonly attribute double? currentTime;
}; };
interface DocumentTimeline : AnimationTimeline {
};
</script> </script>
<script> <script>
'use strict'; 'use strict';
@ -18,8 +21,8 @@ var idlArray;
test(function() { test(function() {
idlArray = new IdlArray(); idlArray = new IdlArray();
idlArray.add_idls( idlArray.add_idls(
document.getElementById('AnimationTimeline-IDL').textContent); document.getElementById('DocumentTimeline-IDL').textContent);
idlArray.add_objects( { AnimationTimeline: ['document.timeline'] } ); idlArray.add_objects( { DocumentTimeline: ['document.timeline'] } );
}); });
idlArray.test(); idlArray.test();

View file

@ -13,20 +13,18 @@ document.body.appendChild(iframe);
</script> </script>
<div id=log></div> <div id=log></div>
<script> <script>
var t = async_test(); onload = function() {
onload = t.step_func(function() {
window[0].postMessage(1, location.href, []); window[0].postMessage(1, location.href, []);
window[1].postMessage(2, url, []); window[1].postMessage(2, url, []);
var i = 0; var i = 0;
onmessage = t.step_func(function(e) { onmessage = function(e) {
i++; i++;
assert_equals(e.data[0], i); assert_equals(e.data[0], i);
assert_equals(e.data[1], location.protocol + '//' + location.host); assert_equals(e.data[1], location.protocol + '//' + location.host);
if (i === 2) { if (i === 2) {
t.done(); done();
} }
}); };
setTimeout(t.step_func(function() { assert_unreached("Only got " + i + " events before timeout, expected 2") }), 1000); };
});
</script> </script>

View file

@ -13,20 +13,18 @@ document.body.appendChild(iframe);
</script> </script>
<div id=log></div> <div id=log></div>
<script> <script>
var t = async_test(); onload = function() {
onload = t.step_func(function() {
window[0].postMessage(1, '*', []); window[0].postMessage(1, '*', []);
window[1].postMessage(2, '*', []); window[1].postMessage(2, '*', []);
var i = 0; var i = 0;
onmessage = t.step_func(function(e) { onmessage = function(e) {
i++; i++;
assert_equals(e.data[0], i); assert_equals(e.data[0], i);
assert_equals(e.data[1], location.protocol + '//' + location.host); assert_equals(e.data[1], location.protocol + '//' + location.host);
if (i === 2) { if (i === 2) {
t.done(); done();
} }
}); };
setTimeout(t.step_func(function() { assert_unreached("Only got " + i + " events before timeout, expected 2") }), 1000); };
});
</script> </script>

View file

@ -13,20 +13,18 @@ document.body.appendChild(iframe);
</script> </script>
<div id=log></div> <div id=log></div>
<script> <script>
var t = async_test(); onload = function() {
onload = t.step_func(function() {
window[0].postMessage(1, location.href); window[0].postMessage(1, location.href);
window[1].postMessage(2, url); window[1].postMessage(2, url);
var i = 0; var i = 0;
onmessage = t.step_func(function(e) { onmessage = function(e) {
i++; i++;
assert_equals(e.data[0], i); assert_equals(e.data[0], i);
assert_equals(e.data[1], location.protocol + '//' + location.host); assert_equals(e.data[1], location.protocol + '//' + location.host);
if (i == 2) { if (i == 2) {
t.done(); done();
} }
}); };
setTimeout(t.step_func(function() {assert_unreached("Only got " + i + " events before timeout, expected 2")}), 1000); };
});
</script> </script>

View file

@ -13,20 +13,18 @@ document.body.appendChild(iframe);
</script> </script>
<div id=log></div> <div id=log></div>
<script> <script>
var t = async_test(); onload = function() {
onload = t.step_func(function() {
window[0].postMessage(1, '*'); window[0].postMessage(1, '*');
window[1].postMessage(2, '*'); window[1].postMessage(2, '*');
var i = 0; var i = 0;
onmessage = t.step_func(function(e) { onmessage = function(e) {
i++; i++;
assert_equals(e.data[0], i); assert_equals(e.data[0], i);
assert_equals(e.data[1], location.protocol + '//' + location.host); assert_equals(e.data[1], location.protocol + '//' + location.host);
if (i === 2) { if (i === 2) {
t.done(); done();
} }
}); };
setTimeout(t.step_func(function() { assert_unreached("Only got " + i + " events before timeout, expected 2")}), 1000); };
});
</script> </script>

View file

@ -0,0 +1,149 @@
<!doctype html>
<!--
This test uses no media, and thus does not require fake media devices.
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>RTCPeerConnection No-Media Connection Test</title>
</head>
<body>
<div id="log"></div>
<h2>iceConnectionState info</h2>
<div id="stateinfo">
</div>
<!-- These files are in place when executing on W3C. -->
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/vendor-prefix.js"
data-prefixed-objects=
'[{"ancestors":["window"], "name":"RTCPeerConnection"},
{"ancestors":["window"], "name":"RTCSessionDescription"},
{"ancestors":["window"], "name":"RTCIceCandidate"}]'
>
</script>
<script type="text/javascript">
var test = async_test('Can set up a basic WebRTC call with no data.');
var gFirstConnection = null;
var gSecondConnection = null;
var onOfferCreated = test.step_func(function(offer) {
// TODO: Switch to promise-based interface.
gFirstConnection.setLocalDescription(offer, ignoreSuccess,
failed('setLocalDescription first'));
// This would normally go across the application's signaling solution.
// In our case, the "signaling" is to call this function.
receiveCall(offer.sdp);
});
function receiveCall(offerSdp) {
var parsedOffer = new RTCSessionDescription({ type: 'offer',
sdp: offerSdp });
// These functions use the legacy interface extensions to RTCPeerConnection.
// TODO: Switch to promise-based interfaces.
gSecondConnection.setRemoteDescription(parsedOffer,
function() {
gSecondConnection.createAnswer(onAnswerCreated,
failed('createAnswer'));
},
failed('setRemoteDescription second'));
};
var onAnswerCreated = test.step_func(function(answer) {
gSecondConnection.setLocalDescription(answer, ignoreSuccess,
failed('setLocalDescription second'));
// Similarly, this would go over the application's signaling solution.
handleAnswer(answer.sdp);
});
function handleAnswer(answerSdp) {
var parsedAnswer = new RTCSessionDescription({ type: 'answer',
sdp: answerSdp });
gFirstConnection.setRemoteDescription(parsedAnswer, ignoreSuccess,
failed('setRemoteDescription first'));
};
var onIceCandidateToFirst = test.step_func(function(event) {
// If event.candidate is null = no more candidates.
if (event.candidate) {
var candidate = new RTCIceCandidate(event.candidate);
gSecondConnection.addIceCandidate(candidate);
}
});
var onIceCandidateToSecond = test.step_func(function(event) {
if (event.candidate) {
var candidate = new RTCIceCandidate(event.candidate);
gFirstConnection.addIceCandidate(candidate);
}
});
var onRemoteStream = test.step_func(function(event) {
assert_unreached('WebRTC received a stream when there was none');
});
var onIceConnectionStateChange = test.step_func(function(event) {
assert_equals(event.type, 'iceconnectionstatechange');
var stateinfo = document.getElementById('stateinfo');
stateinfo.innerHTML = 'First: ' + gFirstConnection.iceConnectionState
+ '<br>Second: ' + gSecondConnection.iceConnectionState;
// Note: All these combinations are legal states indicating that the
// call has connected. All browsers should end up in completed/completed,
// but as of this moment, we've chosen to terminate the test early.
// TODO: Revise test to ensure completed/completed is reached.
if (gFirstConnection.iceConnectionState == 'connected' &&
gSecondConnection.iceConnectionState == 'connected') {
test.done()
}
if (gFirstConnection.iceConnectionState == 'connected' &&
gSecondConnection.iceConnectionState == 'completed') {
test.done()
}
if (gFirstConnection.iceConnectionState == 'completed' &&
gSecondConnection.iceConnectionState == 'connected') {
test.done()
}
if (gFirstConnection.iceConnectionState == 'completed' &&
gSecondConnection.iceConnectionState == 'completed') {
test.done()
}
});
// Returns a suitable error callback.
function failed(function_name) {
return test.step_func(function() {
assert_unreached('WebRTC called error callback for ' + function_name);
});
}
// Returns a suitable do-nothing.
function ignoreSuccess(function_name) {
}
// This function starts the test.
test.step(function() {
gFirstConnection = new RTCPeerConnection(null);
gFirstConnection.onicecandidate = onIceCandidateToFirst;
gFirstConnection.oniceconnectionstatechange = onIceConnectionStateChange;
gSecondConnection = new RTCPeerConnection(null);
gSecondConnection.onicecandidate = onIceCandidateToSecond;
gSecondConnection.onaddstream = onRemoteStream;
gSecondConnection.oniceconnectionstatechange = onIceConnectionStateChange;
// The offerToReceiveVideo is necessary and sufficient to make
// an actual connection.
// TODO: Use a promise-based API. This is legacy.
gFirstConnection.createOffer(onOfferCreated, failed('createOffer'),
{offerToReceiveVideo: true});
});
</script>
</body>
</html>

View file

@ -4,19 +4,19 @@
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<div id=log></div> <div id=log></div>
<script> <script>
async_test(function(t) { async_test(function() {
var testResult; var testResult;
var worker = new Worker('./support/WorkerTerminate.js'); var worker = new Worker('./support/WorkerTerminate.js');
worker.onmessage = function(e) { worker.onmessage = this.step_func(function(e) {
testResult = e.data; testResult = e.data;
if (testResult >= 10000) { if (testResult >= 10000) {
worker.terminate(); worker.terminate();
worker.onmessage = t.unreached_func('Unexpected message event'); worker.onmessage = this.unreached_func('Unexpected message event');
setTimeout(t.step_func_done(function() { setTimeout(this.step_func_done(function() {
assert_equals(testResult, 10000); assert_equals(testResult, 10000);
}), 100); }), 100);
} }
}; });
worker.postMessage("ping"); worker.postMessage("ping");
}); });
</script> </script>

View file

@ -12,23 +12,15 @@ close();
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<div id="log"></div> <div id="log"></div>
<script> <script>
async_test(function() { var worker = new Worker('#');
var gotMessage = false; worker.onmessage = function(e) {
var gotError = false; assert_unreached("Got message");
var worker = new Worker('#'); };
worker.onmessage = function(e) { worker.onerror = function(e) {
gotMessage = true; assert_unreached("Got error");
}; };
worker.onerror = function(e) { worker.postMessage(1);
gotError = true; setTimeout(done, 2000);
};
worker.postMessage(1);
setTimeout(this.step_func(function() {
assert_false(gotMessage, 'got message');
assert_true(gotError, 'got error');
this.done();
}), 500);
});
</script> </script>
<!-- <!--
*/ */

View file

@ -18,22 +18,14 @@ var interval2 = setInterval(function() {
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<div id="log"></div> <div id="log"></div>
<script> <script>
async_test(function() { var worker = new Worker('#');
var gotMessage = false; worker.onmessage = function(e) {
var gotError = false; assert_unreached("Got message");
var worker = new Worker('#'); };
worker.onmessage = function(e) { worker.onerror = function(e) {
gotMessage = true; assert_unreached("Got error");
}; };
worker.onerror = function(e) { setTimeout(done, 2000);
gotError = true;
};
setTimeout(this.step_func(function() {
assert_false(gotMessage, 'got message');
assert_true(gotError, 'got error');
this.done();
}), 500);
});
</script> </script>
<!-- <!--
*/ */

View file

@ -14,27 +14,15 @@ setTimeout(x, 0);
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<div id="log"></div> <div id="log"></div>
<script> <script>
setup({allow_uncaught_exception: true}); var worker = new Worker('#');
worker.onmessage = function(e) {
async_test(function() { assert_unreached("Got message");
var gotMessage = false; };
var gotError = false; worker.onerror = function(e) {
var worker = new Worker('#'); assert_unreached("Got error");
worker.onmessage = function(e) { };
gotMessage = true; setTimeout(done, 2000);
};
worker.onerror = function(e) {
gotError = true;
};
setTimeout(this.step_func(function() {
assert_false(gotMessage, 'got message');
assert_true(gotError, 'got error');
this.done();
}), 500);
});
</script> </script>
<!-- <!--
*/ */
//--> //-->