Update web-platform-tests to revision 697b971060b2d475a73c1c3755232a4674d61cf5

This commit is contained in:
Ms2ger 2016-05-10 11:29:19 +02:00
parent f60598909a
commit b97474fbba
236 changed files with 4817 additions and 893 deletions

View file

@ -0,0 +1,45 @@
<!DOCTYPE html>
<title>IDBCursor.update() - index - throw InvalidStateError when the cursor is being iterated</title>
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
<link rel="help" href="https://www.w3.org/TR/IndexedDB/#widl-IDBCursor-update-IDBRequest-any-value">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<div id="log"></div>
<script>
var db,
t = async_test(),
records = [ { pKey: "primaryKey_0", iKey: "indexKey_0" },
{ pKey: "primaryKey_1", iKey: "indexKey_1" } ];
var open_rq = createdb(t);
open_rq.onupgradeneeded = function(e) {
db = e.target.result;
var objStore = db.createObjectStore("store", { keyPath: "pKey" });
objStore.createIndex("index", "iKey");
for (var i = 0; i < records.length; i++)
objStore.add(records[i]);
};
open_rq.onsuccess = function(e) {
var cursor_rq = db.transaction("store", "readwrite")
.objectStore("store")
.index("index")
.openCursor();
cursor_rq.onsuccess = t.step_func(function(e) {
var cursor = e.target.result;
assert_true(cursor instanceof IDBCursor, "cursor exists");
cursor.continue();
assert_throws("InvalidStateError", function() {
cursor.update({ pKey: "primaryKey_0", iKey: "indexKey_0_updated" });
});
t.done();
});
}
</script>

View file

@ -0,0 +1,45 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>IDBCursor.update() - object store - throw InvalidStateError when the cursor is being iterated</title>
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
<link rel="help" href="https://www.w3.org/TR/IndexedDB/#widl-IDBCursor-update-IDBRequest-any-value">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support.js"></script>
<div id="log"></div>
<script>
var db,
t = async_test(),
records = [{ pKey: "primaryKey_0", value: "value_0" },
{ pKey: "primaryKey_1", value: "value_1" }];
var open_rq = createdb(t);
open_rq.onupgradeneeded = function (event) {
db = event.target.result;
var objStore = db.createObjectStore("store", {keyPath : "pKey"});
for (var i = 0; i < records.length; i++) {
objStore.add(records[i]);
}
}
open_rq.onsuccess = function(e) {
var cursor_rq = db.transaction("store", "readwrite")
.objectStore("store")
.openCursor();
cursor_rq.onsuccess = t.step_func(function(event) {
var cursor = event.target.result;
assert_true(cursor instanceof IDBCursor, "cursor exists");
cursor.continue();
assert_throws("InvalidStateError", function() {
cursor.update({ pKey: "primaryKey_0", value: "value_0_updated" });
});
t.done();
});
}
</script>

View file

@ -88,7 +88,7 @@ interface IDBDatabase : EventTarget {
};
interface IDBObjectStore {
readonly attribute DOMString name;
attribute DOMString name;
readonly attribute any keyPath;
readonly attribute DOMStringList indexNames;
readonly attribute IDBTransaction transaction;
@ -106,7 +106,7 @@ interface IDBObjectStore {
};
interface IDBIndex {
readonly attribute DOMString name;
attribute DOMString name;
readonly attribute IDBObjectStore objectStore;
readonly attribute any keyPath;
readonly attribute boolean multiEntry;

View file

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<title>XMLHttpRequest: open() in document that is not fully active (but may be active) should throw</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://xhr.spec.whatwg.org/#the-open()-method">
</head>
<body>
<div id="log"></div>
<script>
var test = async_test(),
client,
count = 0,
win = window.open("resources/init.htm");
test.add_cleanup(function() { win.close(); });
function init() {
test.step(function() {
if(0 == count) {
var doc = win.document;
var ifr = document.createElement("iframe");
ifr.onload = function() {
// Again, do things async so we're not doing loads from inside
// load events.
setTimeout(function() {
client = new ifr.contentWindow.XMLHttpRequest();
count++;
// Important to do a normal navigation, not a reload.
win.location.href = "resources/init.htm";
}, 100);
}
doc.body.appendChild(ifr);
} else if(1 == count) {
assert_throws("InvalidStateError", function() { client.open("GET", "...") })
test.done()
}
})
}
</script>
</body>
</html>

View file

@ -4,6 +4,17 @@
<title>support init file</title>
</head>
<body>
<script> parent.init() </script>
<script>
onload = function() {
// Run async, because navigations from inside onload can be a bit weird.
setTimeout(function() {
if (parent != window) {
parent.init()
} else {
opener.init();
}
}, 0);
}
</script>
</body>
</html>

View file

@ -5,9 +5,11 @@
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
<style type="text/css">
p {
font-size: 50px;
text-decoration: underline;
color: green;
}
p.underline {
text-decoration: underline;
}
</style>
<div><p>Pass if text underline is green!!!</p></div>
<div><p class="underline">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p></div>

View file

@ -1,6 +1,6 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>webkit-text-fill-color should take effect while rendering text-decoration underline</title>
<title>webkit-text-fill-color should not take effect while rendering text-decoration underline</title>
<link rel="author" title="Jeremy Chen" href="jeremychen@mozilla.com">
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
<link rel="help" href="https://compat.spec.whatwg.org/#the-webkit-text-fill-color">
@ -8,10 +8,12 @@
<link rel="match" href="webkit-text-fill-color-property-005-ref.html">
<style type="text/css">
p {
font-size: 50px;
color: green;
}
p.underline {
text-decoration: underline;
color: red;
-webkit-text-fill-color: green;
-webkit-text-fill-color: red
}
</style>
<div><p>Pass if text underline is green!!!</p></div>
<div><p class="underline">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p></div>

View file

@ -17,6 +17,13 @@ var url = CROSSDOMAIN + 'resources/cors-cookie.py?ident='
* widthCredentials
*/
// XXX Do some https tests here as well
test(function () {
var client = new XMLHttpRequest()
client.open('GET', CROSSDOMAIN, false)
client.withCredentials = true;
}, 'Setting withCredentials on a sync XHR object should not throw')
async_test(function () {
var id = new Date().getTime() + '_1',
client = new XMLHttpRequest()

View file

@ -377,6 +377,26 @@ test(function () {
assert_equals(secondelem.classList[0],'foo');
assert_equals(secondelem.classList[1],'bar');
}, 'classList must have [PutForwards=value]');
test(function () {
var foo = document.createElement('div');
foo.className = 'a';
foo.classList.replace('token1', 'token2');
assert_equals(foo.className, 'a');
foo.classList.replace('a', 'b');
assert_equals(foo.className, 'b');
assert_throws('SYNTAX_ERR', function () { foo.classList.replace('t with space', '') });
assert_throws('INVALID_CHARACTER_ERR', function () { foo.classList.replace('t with space', 'foo') });
assert_throws('SYNTAX_ERR', function () { foo.classList.replace('', 'foo') });
}, 'classList.replace should work');
test(function() {
var foo = document.createElement('div');
assert_throws(new TypeError(),
function() { foo.classList.supports('hello') });
}, 'classList.supports should throw');
</script>
</head>
<body>

View file

@ -2,4 +2,3 @@
@ChrisParis
@deniak
@jdm
@Ms2ger

View file

@ -0,0 +1,131 @@
<!doctype html>
<title>createContextualFragment() tests</title>
<div id=log></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
// We are not testing XML documents here, because apparently it's not clear
// what we want to happen there. We also aren't testing the HTML parser in any
// depth, just some basic sanity checks.
// Exception-throwing
test(function() {
var range = document.createRange();
range.detach();
range.createContextualFragment("");
}, "Must not throw INVALID_STATE_ERR for a detached node.");
test(function() {
var range = document.createRange();
assert_throws(new TypeError(), function() {
range.createContextualFragment();
});
}, "Must throw TypeError when calling without arguments");
test(function() {
// Simple test
var range = document.createRange();
range.selectNodeContents(document.body);
var fragment = "<p CLaSs=testclass> Hi! <p>Hi!";
var expected = document.createDocumentFragment();
var tmpNode = document.createElement("p");
tmpNode.setAttribute("class", "testclass");
tmpNode.appendChild(document.createTextNode(" Hi! "));
expected.appendChild(tmpNode);
tmpNode = document.createElement("p");
tmpNode.appendChild(document.createTextNode("Hi!"));
expected.appendChild(tmpNode);
var result = range.createContextualFragment(fragment);
assert_true(expected.isEqualNode(result),
"Unexpected result (collapsed Range)");
// Token test that the end node makes no difference
range.setEnd(document.body.getElementsByTagName("script")[0], 0);
result = range.createContextualFragment(fragment);
assert_true(expected.isEqualNode(result),
"Unexpected result (Range ends in <script>)");
}, "Simple test with paragraphs");
test(function() {
// This test based on https://bugzilla.mozilla.org/show_bug.cgi?id=585819,
// from a real-world compat bug
var range = document.createRange();
range.selectNodeContents(document.documentElement);
var fragment = "<span>Hello world</span>";
var expected = document.createDocumentFragment();
var tmpNode = document.createElement("span");
tmpNode.appendChild(document.createTextNode("Hello world"));
expected.appendChild(tmpNode);
var result = range.createContextualFragment(fragment);
assert_true(expected.isEqualNode(result),
"Unexpected result (collapsed Range)");
// Another token test that the end node makes no difference
range.setEnd(document.head, 0);
result = range.createContextualFragment(fragment);
assert_true(expected.isEqualNode(result),
"Unexpected result (Range ends in <head>)");
}, "Don't auto-create <body> when applied to <html>");
// Scripts should be run if inserted (that's what the "Unmark all scripts
// . . ." line means, I'm told)
var passed = false;
test(function() {
assert_false(passed, "Sanity check");
var range = document.createRange();
range.selectNodeContents(document.documentElement);
var fragment = range.createContextualFragment("<script>passed = true</s" + "cript>");
assert_false(passed, "Fragment created but not yet added to document, should not have run");
document.body.appendChild(fragment);
assert_true(passed, "Fragment created and added to document, should run");
}, "<script>s should be run when appended to the document (but not before)");
// Now that we've established basic sanity, let's do equivalence tests. Those
// are easier to write anyway.
function testEquivalence(element1, fragment1, element2, fragment2) {
var range1 = element1.ownerDocument.createRange();
range1.selectNodeContents(element1);
var range2 = element2.ownerDocument.createRange();
range2.selectNodeContents(element2);
var result1 = range1.createContextualFragment(fragment1);
var result2 = range2.createContextualFragment(fragment2);
assert_true(result1.isEqualNode(result2), "Results are supposed to be equivalent");
// Throw in partial ownerDocument tests on the side, since the algorithm
// does specify that and we don't want to completely not test it.
if (result1.firstChild != null) {
assert_equals(result1.firstChild.ownerDocument, element1.ownerDocument,
"ownerDocument must be set to that of the reference node");
}
if (result2.firstChild != null) {
assert_equals(result2.firstChild.ownerDocument, element2.ownerDocument,
"ownerDocument must be set to that of the reference node");
}
}
var tests = [
["<html> and <body> must work the same, 1", document.documentElement, "<span>Hello world</span>", document.body, "<span>Hello world</span>"],
["<html> and <body> must work the same, 2", document.documentElement, "<body><p>Hello world", document.body, "<body><p>Hello world"],
["Implicit <body> creation", document.documentElement, "<body><p>", document.documentElement, "<p>"],
["Namespace generally shouldn't matter",
document.createElementNS("http://fake-namespace", "div"), "<body><p><span>Foo",
document.createElement("div"), "<body><p><span>Foo"],
["<html> in a different namespace shouldn't be special",
document.createElementNS("http://fake-namespace", "html"), "<body><p>",
document.createElement("div"), "<body><p>"],
["null should be stringified", document.createElement("span"), null, document.createElement("span"), "null"],
["undefined should be stringified", document.createElement("span"), undefined, document.createElement("span"), "undefined"]/*,
// FIXME: Spec doesn't say what to do about non-Elements!
["Text nodes?",
document.createTextNode("?"), "<span>",
document.createTextNode("?"), "<span>"]*/
];
generate_tests(testEquivalence, tests);
</script>

View file

@ -0,0 +1,28 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>innerHTML in XHTML: getting while the document is in an invalid state</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
<link rel="help" href="https://w3c.github.io/DOM-Parsing/#widl-Element-innerHTML"/>
<link rel="help" href="http://www.whatwg.org/html5/#xml-fragment-serialization-algorithm"/>
<link rel="help" href="http://www.whatwg.org/html5/#document.title"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<script>
test(function() {
document.documentElement.appendChild(document.createElement("test:test"));
assert_throws("INVALID_STATE_ERR", function() {
document.documentElement.innerHTML;
}, "getting element with \":\" in its local name");
});
test(function() {
document.title = "\f";
assert_throws("INVALID_STATE_ERR", function() {
document.getElementsByTagName("title")[0].innerHTML;
}, "Getting a Text node whose data contains characters that are not matched by the XML Char production");
});
</script>
</body>
</html>

View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>innerHTML in XHTML</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
<link rel="help" href="http://html5.org/specs/dom-parsing.html#dom-innerhtml"/>
<link rel="help" href="http://www.whatwg.org/html5/#xml-fragment-serialization-algorithm"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<script><![CDATA[
test(function() {
var el = document.createElement("div");
el.appendChild(document.createElement("xmp"))
.appendChild(document.createElement("span"))
.appendChild(document.createTextNode("<"));
assert_equals(el.innerHTML, "<xmp xmlns=\"http://www.w3.org/1999/xhtml\"><span>&lt;<\/span><\/xmp>");
})
test(function() {
var el = document.createElement("xmp");
el.appendChild(document.createElement("span"))
.appendChild(document.createTextNode("<"));
assert_equals(el.innerHTML, "<span xmlns=\"http://www.w3.org/1999/xhtml\">&lt;<\/span>");
})
test(function() {
var el = document.createElement("xmp");
el.appendChild(document.createTextNode("<"));
assert_equals(el.innerHTML, "&lt;");
})
test(function() {
var el = document.createElement("div");
el.appendChild(document.createElement("br"));
assert_equals(el.innerHTML, "<br xmlns=\"http://www.w3.org/1999/xhtml\" />");
})
test(function() {
var el = document.createElement("div");
el.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "html:br"));
assert_equals(el.innerHTML, "<html:br xmlns:html=\"http://www.w3.org/1999/xhtml\" />");
})
test(function() {
var el = document.createElement("div");
el.appendChild(document.createTextNode("<>\"'&"));
assert_equals(el.innerHTML, "&lt;&gt;\"'&amp;");
})
test(function() {
var el = document.createElement("div");
el.appendChild(document.createTextNode("&lt;&gt;&quot;&apos;&amp;"));
assert_equals(el.innerHTML, "&amp;lt;&amp;gt;&amp;quot;&amp;apos;&amp;amp;");
})
test(function() {
var el = document.createElement("div");
el.appendChild(document.createTextNode("àו…\u00A0"));
assert_equals(el.innerHTML, "àו…\u00A0");
})
]]></script>
</body>
</html>

View file

@ -0,0 +1,24 @@
<!DOCTYPE html>
<title>innerHTML in HTML</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://w3c.github.io/DOM-Parsing/#widl-Element-innerHTML">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function testIsChild(p, c) {
assert_equals(p.firstChild, c);
assert_equals(c.parentNode, p);
}
test(function() {
var p = document.createElement('p');
var b = p.appendChild(document.createElement('b'));
var t = b.appendChild(document.createTextNode("foo"));
testIsChild(p, b);
testIsChild(b, t);
assert_equals(t.data, "foo");
p.innerHTML = "";
testIsChild(b, t);
assert_equals(t.data, "foo");
}, "innerHTML should leave the removed children alone.")
</script>

View file

@ -0,0 +1,26 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>innerHTML in XHTML</title>
<link rel="author" title="Simon Pieters" href="mailto:simonp@opera.com"/>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
<link rel="help" href="http://html5.org/specs/dom-parsing.html#dom-innerhtml"/>
<link rel="help" href="http://www.whatwg.org/html5/#xml-fragment-serialization-algorithm"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<iframe src="data:text/xml,&lt;html xmlns='http://www.w3.org/1999/xhtml'>&lt;foo--/>&lt;/html>"></iframe>
<script><![CDATA[
var t = async_test();
window.onload = t.step_func(function() {
var foo = window[0].document.documentElement.firstChild;
assert_throws('SyntaxError', function() {
foo.innerHTML = 'x<\/foo--><\!--y';
// This is ridiculous.
});
t.done();
});
]]></script>
</body>
</html>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>math in html: innerHTML</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>math in html: innerHTML</h1>
<div id="log"></div>
<div style="display:none">
<div id="d1"><math><mi>x</mi></math></div>
</div>
<script>
test(function() {
var math = document.getElementById("d1").firstChild;
assert_equals(math.innerHTML, "<mi>x</mi>");
},"innerHTML defined on math.");
</script>

View file

@ -0,0 +1,49 @@
<!DOCTYPE html>
<title>innerHTML and string conversion</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="http://domparsing.spec.whatwg.org/#extensions-to-the-element-interface">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var p = document.createElement("p");
p.innerHTML = null;
assert_equals(p.innerHTML, "");
assert_equals(p.textContent, "");
}, "innerHTML and string conversion: null.")
test(function() {
var p = document.createElement("p");
p.innerHTML = undefined;
assert_equals(p.innerHTML, "undefined");
assert_equals(p.textContent, "undefined");
}, "innerHTML and string conversion: undefined.")
test(function() {
var p = document.createElement("p");
p.innerHTML = 42;
assert_equals(p.innerHTML, "42");
assert_equals(p.textContent, "42");
}, "innerHTML and string conversion: number.")
test(function() {
var p = document.createElement("p");
p.innerHTML = {
toString: function() { return "pass"; },
valueOf: function() { return "fail"; }
};
assert_equals(p.innerHTML, "pass");
assert_equals(p.textContent, "pass");
}, "innerHTML and string conversion: toString.")
test(function() {
var p = document.createElement("p");
p.innerHTML = {
toString: undefined,
valueOf: function() { return "pass"; }
};
assert_equals(p.innerHTML, "pass");
assert_equals(p.textContent, "pass");
}, "innerHTML and string conversion: valueOf.")
</script>

View file

@ -0,0 +1,94 @@
<!DOCTYPE HTML>
<html>
<head>
<title>insertAdjacentHTML in HTML</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="insert_adjacent_html.js"></script>
</head>
<body>
<p id="display"></p><div id="content" style="display: none"></div><div id="content2" style="display: none"></div>
<script>
var script_ran = false;
function testPositions(node, testDesc) {
test(function() {
script_ran = false;
node.insertAdjacentHTML("beforeBegin", "\u003Cscript>script_ran = true;\u003C/script><i></i>");
assert_equals(node.previousSibling.localName, "i", "Should have had <i> as previous sibling");
assert_equals(node.previousSibling.previousSibling.localName, "script", "Should have had <script> as second previous child");
assert_false(script_ran, "script should not have run");
}, "beforeBegin " + node.id + " " + testDesc)
test(function() {
script_ran = false;
node.insertAdjacentHTML("Afterbegin", "<b></b>\u003Cscript>script_ran = true;\u003C/script>");
assert_equals(node.firstChild.localName, "b", "Should have had <b> as first child");
assert_equals(node.firstChild.nextSibling.localName, "script", "Should have had <script> as second child");
assert_false(script_ran, "script should not have run");
}, "Afterbegin " + node.id + " " + testDesc);
test(function() {
script_ran = false;
node.insertAdjacentHTML("BeforeEnd", "\u003Cscript>script_ran = true;\u003C/script><u></u>");
assert_equals(node.lastChild.localName, "u", "Should have had <u> as last child");
assert_equals(node.lastChild.previousSibling.localName, "script", "Should have had <script> as penultimate child");
assert_false(script_ran, "script should not have run");
}, "BeforeEnd " + node.id + " " + testDesc)
test(function() {
script_ran = false;
node.insertAdjacentHTML("afterend", "<a></a>\u003Cscript>script_ran = true;\u003C/script>");
assert_equals(node.nextSibling.localName, "a", "Should have had <a> as next sibling");
assert_equals(node.nextSibling.nextSibling.localName, "script", "Should have had <script> as second next sibling");
assert_false(script_ran, "script should not have run");
}, "afterend " + node.id + " " + testDesc)
}
var content = document.getElementById("content");
testPositions(content, "without next sibling");
testPositions(content, "again, with next sibling");
test(function() {
assert_throws("SYNTAX_ERR", function() {content.insertAdjacentHTML("bar", "foo")});
assert_throws("SYNTAX_ERR", function() {content.insertAdjacentHTML("beforebegİn", "foo")});
assert_throws("SYNTAX_ERR", function() {content.insertAdjacentHTML("beforebegın", "foo")});
}, "Should throw when inserting with invalid position string");
var parentElement = document.createElement("div");
var child = document.createElement("div");
child.id = "child";
testThrowingNoParent(child, "null");
testThrowingNoParent(document.documentElement, "a document");
test(function() {
child.insertAdjacentHTML("afterBegin", "foo");
child.insertAdjacentHTML("beforeend", "bar");
assert_equals(child.textContent, "foobar");
parentElement.appendChild(child);
}, "Inserting after being and before end should order things correctly");
testPositions(child, "node not in tree but has parent");
test(function() {
script_ran = false;
content.appendChild(parentElement); // must not run scripts
assert_false(script_ran, "script should not have run");
}, "Should not run script when appending things which have descendant <script> inserted via insertAdjacentHTML");
var content2 = document.getElementById("content2");
testPositions(content2, "without next sibling");
testPositions(content2, "test again, now that there's a next sibling");
// HTML only
test(function() {
document.body.insertAdjacentHTML("afterend", "<p>");
document.head.insertAdjacentHTML("beforebegin", "<p>");
assert_equals(document.getElementsByTagName("head").length, 1, "Should still have one head");
assert_equals(document.getElementsByTagName("body").length, 1, "Should still have one body");
}, "Inserting kids of the <html> element should not do weird things with implied <body>/<head> tags")
</script>
<div id="log"></div>
</body>
</html>

View file

@ -0,0 +1,33 @@
function testThrowingNoParent(element, desc) {
test(function() {
assert_throws("NO_MODIFICATION_ALLOWED_ERR",
function() { element.insertAdjacentHTML("afterend", "") }
);
assert_throws("NO_MODIFICATION_ALLOWED_ERR",
function() { element.insertAdjacentHTML("beforebegin", "") }
);
assert_throws("NO_MODIFICATION_ALLOWED_ERR",
function() { element.insertAdjacentHTML("afterend", "foo") }
);
assert_throws("NO_MODIFICATION_ALLOWED_ERR",
function() { element.insertAdjacentHTML("beforebegin", "foo") }
);
}, "When the parent node is " + desc + ", insertAdjacentHTML should throw for beforebegin and afterend (text)");
test(function() {
assert_throws("NO_MODIFICATION_ALLOWED_ERR",
function() { element.insertAdjacentHTML("afterend", "<!-- fail -->") }
);
assert_throws("NO_MODIFICATION_ALLOWED_ERR",
function() { element.insertAdjacentHTML("beforebegin", "<!-- fail -->") }
);
}, "When the parent node is " + desc + ", insertAdjacentHTML should throw for beforebegin and afterend (comments)");
test(function() {
assert_throws("NO_MODIFICATION_ALLOWED_ERR",
function() { element.insertAdjacentHTML("afterend", "<div></div>") }
);
assert_throws("NO_MODIFICATION_ALLOWED_ERR",
function() { element.insertAdjacentHTML("beforebegin", "<div></div>") }
);
}, "When the parent node is " + desc + ", insertAdjacentHTML should throw for beforebegin and afterend (elements)");
}

View file

@ -0,0 +1,91 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>insertAdjacentHTML in HTML</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="insert_adjacent_html.js"></script>
</head>
<body>
<p id="display"></p><div id="content" style="display: none"></div><div id="content2" style="display: none"></div>
<script><![CDATA[
var script_ran = false;
function testPositions(node, testDesc) {
test(function() {
script_ran = false;
node.insertAdjacentHTML("beforeBegin", "\u003Cscript>script_ran = true;\u003C/script><i></i>");
assert_equals(node.previousSibling.localName, "i", "Should have had <i> as previous sibling");
assert_equals(node.previousSibling.previousSibling.localName, "script", "Should have had <script> as second previous child");
assert_false(script_ran, "script should not have run");
}, "beforeBegin " + node.id + " " + testDesc)
test(function() {
script_ran = false;
node.insertAdjacentHTML("Afterbegin", "<b></b>\u003Cscript>script_ran = true;\u003C/script>");
assert_equals(node.firstChild.localName, "b", "Should have had <b> as first child");
assert_equals(node.firstChild.nextSibling.localName, "script", "Should have had <script> as second child");
assert_false(script_ran, "script should not have run");
}, "Afterbegin " + node.id + " " + testDesc);
test(function() {
script_ran = false;
node.insertAdjacentHTML("BeforeEnd", "\u003Cscript>script_ran = true;\u003C/script><u></u>");
assert_equals(node.lastChild.localName, "u", "Should have had <u> as last child");
assert_equals(node.lastChild.previousSibling.localName, "script", "Should have had <script> as penultimate child");
assert_false(script_ran, "script should not have run");
}, "BeforeEnd " + node.id + " " + testDesc)
test(function() {
script_ran = false;
node.insertAdjacentHTML("afterend", "<a></a>\u003Cscript>script_ran = true;\u003C/script>");
assert_equals(node.nextSibling.localName, "a", "Should have had <a> as next sibling");
assert_equals(node.nextSibling.nextSibling.localName, "script", "Should have had <script> as second next sibling");
assert_false(script_ran, "script should not have run");
}, "afterend " + node.id + " " + testDesc)
}
var content = document.getElementById("content");
testPositions(content, "without next sibling");
testPositions(content, "again, with next sibling");
test(function() {
assert_throws("SYNTAX_ERR", function() {content.insertAdjacentHTML("bar", "foo")});
assert_throws("SYNTAX_ERR", function() {content.insertAdjacentHTML("beforebegİn", "foo")});
assert_throws("SYNTAX_ERR", function() {content.insertAdjacentHTML("beforebegın", "foo")});
}, "Should throw when inserting with invalid position string");
var parentElement = document.createElement("div");
var child = document.createElement("div");
child.id = "child";
testThrowingNoParent(child, "null");
testThrowingNoParent(document.documentElement, "a document");
test(function() {
child.insertAdjacentHTML("afterBegin", "foo");
child.insertAdjacentHTML("beforeend", "bar");
assert_equals(child.textContent, "foobar");
parentElement.appendChild(child);
}, "Inserting after being and before end should order things correctly");
testPositions(child, "node not in tree but has parent");
test(function() {
script_ran = false;
content.appendChild(parentElement); // must not run scripts
assert_false(script_ran, "script should not have run");
}, "Should not run script when appending things which have descendant <script> inserted via insertAdjacentHTML");
var content2 = document.getElementById("content2");
testPositions(content2, "without next sibling");
testPositions(content2, "test again, now that there's a next sibling");
// XML-only:
test(function() {
assert_throws("SYNTAX_ERR", function() {content.insertAdjacentHTML("beforeend", "<p>")});
});
]]></script>
<div id="log"></div>
</body>
</html>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>outerHTML: child of #document</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="http://html5.org/specs/dom-parsing.html#outerhtml">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
assert_throws("NO_MODIFICATION_ALLOWED_ERR", function() {
document.documentElement.outerHTML = "<html><p>FAIL: Should have thrown an error<\/p><\/html>";
})
});
</script>

View file

@ -0,0 +1,54 @@
<!DOCTYPE html>
<title>outerHTML and string conversion</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="http://domparsing.spec.whatwg.org/#extensions-to-the-element-interface">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var div = document.createElement("div");
var p = div.appendChild(document.createElement("p"));
p.outerHTML = null;
assert_equals(div.innerHTML, "");
assert_equals(div.textContent, "");
}, "outerHTML and string conversion: null.")
test(function() {
var div = document.createElement("div");
var p = div.appendChild(document.createElement("p"));
p.outerHTML = undefined;
assert_equals(div.innerHTML, "undefined");
assert_equals(div.textContent, "undefined");
}, "outerHTML and string conversion: undefined.")
test(function() {
var div = document.createElement("div");
var p = div.appendChild(document.createElement("p"));
p.outerHTML = 42;
assert_equals(div.innerHTML, "42");
assert_equals(div.textContent, "42");
}, "outerHTML and string conversion: number.")
test(function() {
var div = document.createElement("div");
var p = div.appendChild(document.createElement("p"));
p.outerHTML = {
toString: function() { return "pass"; },
valueOf: function() { return "fail"; }
};
assert_equals(div.innerHTML, "pass");
assert_equals(div.textContent, "pass");
}, "outerHTML and string conversion: toString.")
test(function() {
var div = document.createElement("div");
var p = div.appendChild(document.createElement("p"));
p.outerHTML = {
toString: undefined,
valueOf: function() { return "pass"; }
};
assert_equals(div.innerHTML, "pass");
assert_equals(div.textContent, "pass");
}, "outerHTML and string conversion: valueOf.")
</script>

View file

@ -0,0 +1,91 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XML serialization</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<script><![CDATA[
function serialize(node) {
var serializer = new XMLSerializer();
return serializer.serializeToString(node);
}
test(function() {
var dt = document.createComment("--");
assert_equals(serialize(dt), '<!------>');
}, "Comment: containing --");
test(function() {
var dt = document.createComment("- x");
assert_equals(serialize(dt), '<!--- x-->');
}, "Comment: starting with -");
test(function() {
var dt = document.createComment("x -");
assert_equals(serialize(dt), '<!--x --->');
}, "Comment: ending with -");
test(function() {
var dt = document.createComment("-->");
assert_equals(serialize(dt), '<!---->-->');
}, "Comment: containing -->");
test(function() {
var dt = document.implementation.createDocumentType("html", "", "");
assert_equals(serialize(dt), '<!DOCTYPE html>');
}, "DocumentType: empty public and system id");
test(function() {
var dt = document.implementation.createDocumentType("html", "a", "");
assert_equals(serialize(dt), '<!DOCTYPE html PUBLIC "a">');
}, "DocumentType: empty system id");
test(function() {
var dt = document.implementation.createDocumentType("html", "", "a");
assert_equals(serialize(dt), '<!DOCTYPE html SYSTEM "a">');
}, "DocumentType: empty public id");
test(function() {
var dt = document.implementation.createDocumentType("html", "a", "b");
assert_equals(serialize(dt), '<!DOCTYPE html PUBLIC "a" "b">');
}, "DocumentType: non-empty public and system id");
test(function() {
var dt = document.implementation.createDocumentType("html", "'", "'");
assert_equals(serialize(dt), "<!DOCTYPE html PUBLIC \"'\" \"'\">");
}, "DocumentType: 'APOSTROPHE' (U+0027)");
test(function() {
var dt = document.implementation.createDocumentType("html", '"', '"');
assert_equals(serialize(dt), '<!DOCTYPE html PUBLIC """ """>');
}, "DocumentType: 'QUOTATION MARK' (U+0022)");
test(function() {
var dt = document.implementation.createDocumentType("html", '"\'', '\'"');
assert_equals(serialize(dt), '<!DOCTYPE html PUBLIC ""\'" "\'"">');
}, "DocumentType: 'APOSTROPHE' (U+0027) and 'QUOTATION MARK' (U+0022)");
test(function() {
var pi = document.createProcessingInstruction("a", "");
assert_equals(serialize(pi), "<?a ?>");
}, "ProcessingInstruction: empty data");
test(function() {
var pi = document.createProcessingInstruction("a", "b");
assert_equals(serialize(pi), "<?a b?>");
}, "ProcessingInstruction: non-empty data");
test(function() {
var pi = document.createProcessingInstruction("xml", "b");
assert_equals(serialize(pi), "<?xml b?>");
}, "ProcessingInstruction: target contains xml");
test(function() {
var pi = document.createProcessingInstruction("x:y", "b");
assert_equals(serialize(pi), "<?x:y b?>");
}, "ProcessingInstruction: target contains a 'COLON' (U+003A)");
]]></script>
</body>
</html>

View file

@ -29,14 +29,14 @@
var referrerPolicies = {"givenValues" : [ "",
"no-referrer",
"no-referrer-when-downgrade",
"origin-only",
"origin",
"origin-when-cross-origin",
"unsafe-url"
],
"expectedValues" : ["",
"no-referrer",
"no-referrer-when-downgrade",
"origin-only",
"origin",
"origin-when-cross-origin",
"unsafe-url"
]

View file

@ -17,7 +17,7 @@
var initValuesDict = {"method" : "POST",
"referrer" : "http://{{host}}:{{ports[http][0]}}/",
"referrerPolicy" : "origin-only",
"referrerPolicy" : "origin",
"mode" : "same-origin",
"credentials" : "include",
"cache" : "no-cache",
@ -29,7 +29,7 @@
var expectedInitialized = {"method" : "POST",
"referrer" : "http://{{host}}:{{ports[http][0]}}/",
"referrerPolicy" : "origin-only",
"referrerPolicy" : "origin",
"mode" : "same-origin",
"credentials" : "include",
"cache" : "no-cache",

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