mirror of
https://github.com/servo/servo.git
synced 2025-09-14 17:08:22 +01:00
Update web-platform-tests to revision 58eb04cecbbec2e18531ab440225e38944a9c444
This commit is contained in:
parent
25e8bf69e6
commit
665817d2a6
35333 changed files with 1818077 additions and 16036 deletions
|
@ -1,5 +1,4 @@
|
|||
@ayg
|
||||
@jdm
|
||||
@Ms2ger
|
||||
@zcorpan
|
||||
@zqzhang
|
||||
|
|
|
@ -15,5 +15,21 @@ test(function() {
|
|||
var fooEvent = document.createEvent("CustomEvent");
|
||||
fooEvent.initEvent(type, true, true);
|
||||
target.dispatchEvent(fooEvent);
|
||||
});
|
||||
}, "CustomEvent dispatching.");
|
||||
|
||||
test(function() {
|
||||
var e = document.createEvent("CustomEvent");
|
||||
assert_throws(new TypeError(), function() {
|
||||
e.initCustomEvent();
|
||||
});
|
||||
}, "First parameter to initCustomEvent should be mandatory.");
|
||||
|
||||
test(function() {
|
||||
var e = document.createEvent("CustomEvent");
|
||||
e.initCustomEvent("foo");
|
||||
assert_equals(e.type, "foo", "type");
|
||||
assert_false(e.bubbles, "bubbles");
|
||||
assert_false(e.cancelable, "cancelable");
|
||||
assert_equals(e.detail, null, "detail");
|
||||
}, "initCustomEvent's default parameter values.");
|
||||
</script>
|
||||
|
|
|
@ -116,4 +116,19 @@ async_test(function() {
|
|||
|
||||
this.done()
|
||||
}, "Calling initEvent during propagation.")
|
||||
|
||||
test(function() {
|
||||
var e = document.createEvent("Event")
|
||||
assert_throws(new TypeError(), function() {
|
||||
e.initEvent()
|
||||
})
|
||||
}, "First parameter to initEvent should be mandatory.")
|
||||
|
||||
test(function() {
|
||||
var e = document.createEvent("Event")
|
||||
e.initEvent("type")
|
||||
assert_equals(e.type, "type", "type")
|
||||
assert_false(e.bubbles, "bubbles")
|
||||
assert_false(e.cancelable, "cancelable")
|
||||
}, "Tests initEvent's default parameter values.")
|
||||
</script>
|
||||
|
|
|
@ -34,7 +34,7 @@ interface Event {
|
|||
[Unforgeable] readonly attribute boolean isTrusted;
|
||||
readonly attribute DOMTimeStamp timeStamp;
|
||||
|
||||
void initEvent(DOMString type, boolean bubbles, boolean cancelable);
|
||||
void initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false);
|
||||
};
|
||||
|
||||
dictionary EventInit {
|
||||
|
@ -48,7 +48,7 @@ dictionary EventInit {
|
|||
interface CustomEvent : Event {
|
||||
readonly attribute any detail;
|
||||
|
||||
void initCustomEvent(DOMString type, boolean bubbles, boolean cancelable, any detail);
|
||||
void initCustomEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional any detail = null);
|
||||
};
|
||||
|
||||
dictionary CustomEventInit : EventInit {
|
||||
|
|
|
@ -11,7 +11,6 @@ var pairs = [
|
|||
// Defined in DOM
|
||||
{attr: "classList", sup: ["anyElement"]},
|
||||
// Defined in HTML
|
||||
{attr: "dropzone", sup: ["anyHTMLElement"]},
|
||||
{attr: "htmlFor", sup: ["output"]},
|
||||
{attr: "relList", sup: ["a", "area", "link"]},
|
||||
{attr: "sandbox", sup: ["iframe"]},
|
||||
|
@ -27,7 +26,7 @@ var namespaces = [
|
|||
|
||||
var elements = ["a", "area", "link", "iframe", "output", "td", "th"];
|
||||
function testAttr(pair, new_el){
|
||||
return (pair.attr === "classList" || (new_el.namespaceURI === "http://www.w3.org/1999/xhtml" && (pair.attr === "dropzone" || pair.sup.indexOf(new_el.localName) != -1)));
|
||||
return (pair.attr === "classList" || (new_el.namespaceURI === "http://www.w3.org/1999/xhtml" && pair.sup.indexOf(new_el.localName) != -1));
|
||||
}
|
||||
|
||||
pairs.forEach(function(pair) {
|
||||
|
|
|
@ -5,46 +5,67 @@
|
|||
<script src=/resources/testharnessreport.js></script>
|
||||
<span class=" a a b "></span>
|
||||
<script>
|
||||
test(function() {
|
||||
test(() => {
|
||||
var list = document.querySelector("span").classList;
|
||||
assert_array_equals([...list], ["a", "b"]);
|
||||
}, "classList");
|
||||
|
||||
var keys = list.keys();
|
||||
assert_false(keys instanceof Array);
|
||||
test(() => {
|
||||
var keys = document.querySelector("span").classList.keys();
|
||||
assert_false(keys instanceof Array, "must not be Array");
|
||||
keys = [...keys];
|
||||
assert_array_equals(keys, [0, 1]);
|
||||
}, "classList.keys");
|
||||
|
||||
var values = list.values();
|
||||
assert_false(values instanceof Array);
|
||||
test(() => {
|
||||
var values = document.querySelector("span").classList.values();
|
||||
assert_false(values instanceof Array, "must not be Array");
|
||||
values = [...values];
|
||||
assert_array_equals(values, ["a", "b"]);
|
||||
}, "classList.values");
|
||||
|
||||
var entries = list.entries();
|
||||
assert_false(entries instanceof Array);
|
||||
test(() => {
|
||||
var entries = document.querySelector("span").classList.entries();
|
||||
assert_false(entries instanceof Array, "must not be Array");
|
||||
entries = [...entries];
|
||||
assert_equals(entries.length, keys.length);
|
||||
assert_equals(entries.length, values.length);
|
||||
var keys = [...document.querySelector("span").classList.keys()];
|
||||
var values = [...document.querySelector("span").classList.values()];
|
||||
assert_equals(entries.length, keys.length, "entries.length == keys.length");
|
||||
assert_equals(entries.length, values.length,
|
||||
"entries.length == values.length");
|
||||
for (var i = 0; i < entries.length; ++i) {
|
||||
assert_array_equals(entries[i], [keys[i], values[i]]);
|
||||
assert_array_equals(entries[i], [keys[i], values[i]],
|
||||
"entries[" + i + "]");
|
||||
}
|
||||
}, "classList.entries");
|
||||
|
||||
test(() => {
|
||||
var list = document.querySelector("span").classList;
|
||||
var values = [...list.values()];
|
||||
var keys = [...list.keys()];
|
||||
var entries = [...list.entries()];
|
||||
|
||||
var cur = 0;
|
||||
var thisObj = {};
|
||||
list.forEach(function(value, key, listObj) {
|
||||
assert_equals(listObj, list);
|
||||
assert_equals(this, thisObj);
|
||||
assert_equals(value, values[cur]);
|
||||
assert_equals(key, keys[cur]);
|
||||
assert_equals(listObj, list, "Entry " + cur + " listObj");
|
||||
assert_equals(this, thisObj, "Entry " + cur + " this");
|
||||
assert_equals(value, values[cur], "Entry " + cur + " value");
|
||||
assert_equals(key, keys[cur], "Entry " + cur + " key");
|
||||
cur++;
|
||||
}, thisObj);
|
||||
assert_equals(cur, entries.length);
|
||||
assert_equals(cur, entries.length, "length");
|
||||
}, "classList.forEach");
|
||||
|
||||
assert_equals(list[Symbol.iterator], Array.prototype[Symbol.iterator]);
|
||||
assert_equals(list.keys, Array.prototype.keys);
|
||||
test(() => {
|
||||
var list = document.querySelector("span").classList;
|
||||
assert_equals(list[Symbol.iterator], Array.prototype[Symbol.iterator],
|
||||
"[Symbol.iterator]");
|
||||
assert_equals(list.keys, Array.prototype.keys, ".keys");
|
||||
if (Array.prototype.values) {
|
||||
assert_equals(list.values, Array.prototype.values);
|
||||
assert_equals(list.values, Array.prototype.values, ".values");
|
||||
}
|
||||
assert_equals(list.entries, Array.prototype.entries);
|
||||
assert_equals(list.forEach, Array.prototype.forEach);
|
||||
});
|
||||
assert_equals(list.entries, Array.prototype.entries, ".entries");
|
||||
assert_equals(list.forEach, Array.prototype.forEach, ".forEach");
|
||||
}, "classList inheritance from Array.prototype");
|
||||
</script>
|
||||
|
|
1
tests/wpt/web-platform-tests/dom/lists/README.md
Normal file
1
tests/wpt/web-platform-tests/dom/lists/README.md
Normal file
|
@ -0,0 +1 @@
|
|||
See `../nodes/Element-classlist.html` for more DOMTokenList tests.
|
|
@ -109,6 +109,7 @@ var someNonCreateableEvents = [
|
|||
"PopUpEvent",
|
||||
"PresentationConnectionAvailableEvent",
|
||||
"PresentationConnectionCloseEvent",
|
||||
"ProgressEvent",
|
||||
"PromiseRejectionEvent",
|
||||
"PushEvent",
|
||||
"RTCDTMFToneChangeEvent",
|
||||
|
|
|
@ -20,7 +20,6 @@ var aliases = {
|
|||
"MouseEvents": "MouseEvent",
|
||||
"PageTransitionEvent": "PageTransitionEvent",
|
||||
"PopStateEvent": "PopStateEvent",
|
||||
"ProgressEvent": "ProgressEvent",
|
||||
"StorageEvent": "StorageEvent",
|
||||
"SVGEvents": "Event",
|
||||
"TextEvent": "CompositionEvent",
|
||||
|
|
|
@ -38,6 +38,8 @@ function init(e) {
|
|||
* The level2-lib.js file contains all the common test functions for running each of the aforementioned tests
|
||||
*/
|
||||
|
||||
var method = "matches";
|
||||
|
||||
var docType = "html"; // Only run tests suitable for HTML
|
||||
|
||||
// Prepare the nodes for testing
|
||||
|
@ -64,24 +66,24 @@ function init(e) {
|
|||
fragment.appendChild(element.cloneNode(true));
|
||||
|
||||
// Setup Tests
|
||||
interfaceCheckMatches("Document", doc);
|
||||
interfaceCheckMatches("Detached Element", detached);
|
||||
interfaceCheckMatches("Fragment", fragment);
|
||||
interfaceCheckMatches("In-document Element", element);
|
||||
interfaceCheckMatches(method, "Document", doc);
|
||||
interfaceCheckMatches(method, "Detached Element", detached);
|
||||
interfaceCheckMatches(method, "Fragment", fragment);
|
||||
interfaceCheckMatches(method, "In-document Element", element);
|
||||
|
||||
runSpecialMatchesTests("DIV Element", element);
|
||||
runSpecialMatchesTests("NULL Element", document.createElement("null"));
|
||||
runSpecialMatchesTests("UNDEFINED Element", document.createElement("undefined"));
|
||||
runSpecialMatchesTests(method, "DIV Element", element);
|
||||
runSpecialMatchesTests(method, "NULL Element", document.createElement("null"));
|
||||
runSpecialMatchesTests(method, "UNDEFINED Element", document.createElement("undefined"));
|
||||
|
||||
runInvalidSelectorTestMatches("Document", doc, invalidSelectors);
|
||||
runInvalidSelectorTestMatches("Detached Element", detached, invalidSelectors);
|
||||
runInvalidSelectorTestMatches("Fragment", fragment, invalidSelectors);
|
||||
runInvalidSelectorTestMatches("In-document Element", element, invalidSelectors);
|
||||
runInvalidSelectorTestMatches(method, "Document", doc, invalidSelectors);
|
||||
runInvalidSelectorTestMatches(method, "Detached Element", detached, invalidSelectors);
|
||||
runInvalidSelectorTestMatches(method, "Fragment", fragment, invalidSelectors);
|
||||
runInvalidSelectorTestMatches(method, "In-document Element", element, invalidSelectors);
|
||||
|
||||
runMatchesTest("In-document", doc, validSelectors, "html");
|
||||
runMatchesTest("Detached", detached, validSelectors, "html");
|
||||
runMatchesTest("Fragment", fragment, validSelectors, "html");
|
||||
runMatchesTest(method, "In-document", doc, validSelectors, "html");
|
||||
runMatchesTest(method, "Detached", detached, validSelectors, "html");
|
||||
runMatchesTest(method, "Fragment", fragment, validSelectors, "html");
|
||||
|
||||
runMatchesTest("In-document", doc, scopedSelectors, "html");
|
||||
runMatchesTest(method, "In-document", doc, scopedSelectors, "html");
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,43 +1,47 @@
|
|||
/*
|
||||
* Check that the matches() method exists on the given Node
|
||||
*/
|
||||
function interfaceCheckMatches(type, obj) {
|
||||
function interfaceCheckMatches(method, type, obj) {
|
||||
if (obj.nodeType === obj.ELEMENT_NODE) {
|
||||
test(function() {
|
||||
assert_idl_attribute(obj, "matches", type + " supports matches");
|
||||
}, type + " supports matches")
|
||||
assert_idl_attribute(obj, method, type + " supports " + method);
|
||||
}, type + " supports " + method)
|
||||
} else {
|
||||
test(function() {
|
||||
assert_false(method in obj, type + " supports " + method);
|
||||
}, type + " should not support " + method)
|
||||
}
|
||||
}
|
||||
|
||||
function runSpecialMatchesTests(type, element) {
|
||||
function runSpecialMatchesTests(method, type, element) {
|
||||
test(function() { // 1
|
||||
if (element.tagName.toLowerCase() === "null") {
|
||||
assert_true(element.matches(null), "An element with the tag name '" + element.tagName.toLowerCase() + "' should match.");
|
||||
assert_true(element[method](null), "An element with the tag name '" + element.tagName.toLowerCase() + "' should match.");
|
||||
} else {
|
||||
assert_false(element.matches(null), "An element with the tag name '" + element.tagName.toLowerCase() + "' should not match.");
|
||||
assert_false(element[method](null), "An element with the tag name '" + element.tagName.toLowerCase() + "' should not match.");
|
||||
}
|
||||
}, type + ".matches(null)")
|
||||
}, type + "." + method + "(null)")
|
||||
|
||||
test(function() { // 2
|
||||
if (element.tagName.toLowerCase() === "undefined") {
|
||||
assert_true(element.matches(undefined), "An element with the tag name '" + element.tagName.toLowerCase() + "' should match.");
|
||||
assert_true(element[method](undefined), "An element with the tag name '" + element.tagName.toLowerCase() + "' should match.");
|
||||
} else {
|
||||
assert_false(element.matches(undefined), "An element with the tag name '" + element.tagName.toLowerCase() + "' should not match.");
|
||||
assert_false(element[method](undefined), "An element with the tag name '" + element.tagName.toLowerCase() + "' should not match.");
|
||||
}
|
||||
}, type + ".matches(undefined)")
|
||||
}, type + "." + method + "(undefined)")
|
||||
|
||||
test(function() { // 3
|
||||
assert_throws(TypeError(), function() {
|
||||
element.matches();
|
||||
element[method]();
|
||||
}, "This should throw a TypeError.")
|
||||
}, type + ".matches no parameter")
|
||||
}, type + "." + method + " no parameter")
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute queries with the specified invalid selectors for matches()
|
||||
* Only run these tests when errors are expected. Don't run for valid selector tests.
|
||||
*/
|
||||
function runInvalidSelectorTestMatches(type, root, selectors) {
|
||||
function runInvalidSelectorTestMatches(method, type, root, selectors) {
|
||||
if (root.nodeType === root.ELEMENT_NODE) {
|
||||
for (var i = 0; i < selectors.length; i++) {
|
||||
var s = selectors[i];
|
||||
|
@ -46,14 +50,14 @@ function runInvalidSelectorTestMatches(type, root, selectors) {
|
|||
|
||||
test(function() {
|
||||
assert_throws("SyntaxError", function() {
|
||||
root.matches(q)
|
||||
root[method](q)
|
||||
})
|
||||
}, type + ".matches: " + n + ": " + q);
|
||||
}, type + "." + method + ": " + n + ": " + q);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function runMatchesTest(type, root, selectors, docType) {
|
||||
function runMatchesTest(method, type, root, selectors, docType) {
|
||||
var nodeType = getNodeType(root);
|
||||
|
||||
for (var i = 0; i < selectors.length; i++) {
|
||||
|
@ -75,17 +79,17 @@ function runMatchesTest(type, root, selectors, docType) {
|
|||
for (j = 0; j < e.length; j++) {
|
||||
element = root.querySelector("#" + e[j]);
|
||||
refNode = root.querySelector(ctx);
|
||||
assert_true(element.matches(q, refNode), "The element #" + e[j] + " should match the selector.")
|
||||
assert_true(element[method](q, refNode), "The element #" + e[j] + " should match the selector.")
|
||||
}
|
||||
|
||||
if (u) {
|
||||
for (j = 0; j < u.length; j++) {
|
||||
element = root.querySelector("#" + u[j]);
|
||||
refNode = root.querySelector(ctx);
|
||||
assert_false(element.matches(q, refNode), "The element #" + u[j] + " should not match the selector.")
|
||||
assert_false(element[method](q, refNode), "The element #" + u[j] + " should not match the selector.")
|
||||
}
|
||||
}
|
||||
}, type + " Element.matches: " + n + " (with refNode Element): " + q);
|
||||
}, type + " Element." + method + ": " + n + " (with refNode Element): " + q);
|
||||
}
|
||||
|
||||
if (ref) {
|
||||
|
@ -94,33 +98,33 @@ function runMatchesTest(type, root, selectors, docType) {
|
|||
for (j = 0; j < e.length; j++) {
|
||||
element = root.querySelector("#" + e[j]);
|
||||
refNodes = root.querySelectorAll(ref);
|
||||
assert_true(element.matches(q, refNodes), "The element #" + e[j] + " should match the selector.")
|
||||
assert_true(element[method](q, refNodes), "The element #" + e[j] + " should match the selector.")
|
||||
}
|
||||
|
||||
if (u) {
|
||||
for (j = 0; j < u.length; j++) {
|
||||
element = root.querySelector("#" + u[j]);
|
||||
refNodes = root.querySelectorAll(ref);
|
||||
assert_false(element.matches(q, refNodes), "The element #" + u[j] + " should not match the selector.")
|
||||
assert_false(element[method](q, refNodes), "The element #" + u[j] + " should not match the selector.")
|
||||
}
|
||||
}
|
||||
}, type + " Element.matches: " + n + " (with refNodes NodeList): " + q);
|
||||
}, type + " Element." + method + ": " + n + " (with refNodes NodeList): " + q);
|
||||
}
|
||||
|
||||
if (!ctx && !ref) {
|
||||
test(function() {
|
||||
for (var j = 0; j < e.length; j++) {
|
||||
var element = root.querySelector("#" + e[j]);
|
||||
assert_true(element.matches(q), "The element #" + e[j] + " should match the selector.")
|
||||
assert_true(element[method](q), "The element #" + e[j] + " should match the selector.")
|
||||
}
|
||||
|
||||
if (u) {
|
||||
for (j = 0; j < u.length; j++) {
|
||||
element = root.querySelector("#" + u[j]);
|
||||
assert_false(element.matches(q), "The element #" + u[j] + " should not match the selector.")
|
||||
assert_false(element[method](q), "The element #" + u[j] + " should not match the selector.")
|
||||
}
|
||||
}
|
||||
}, type + " Element.matches: " + n + " (with no refNodes): " + q);
|
||||
}, type + " Element." + method + ": " + n + " (with no refNodes): " + q);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="UTF-8">
|
||||
<title>Selectors-API Level 2 Test Suite: HTML with Selectors Level 3</title>
|
||||
<!-- Selectors API Test Suite Version 3 -->
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/dom/nodes/selectors.js"></script>
|
||||
<script src="/dom/nodes/ParentNode-querySelector-All.js"></script>
|
||||
<script src="Element-matches.js"></script>
|
||||
<style>iframe { visibility: hidden; position: absolute; }</style>
|
||||
|
||||
<div id="log">This test requires JavaScript.</div>
|
||||
|
||||
<script>
|
||||
async_test(function() {
|
||||
var frame = document.createElement("iframe");
|
||||
frame.onload = this.step_func_done(init);
|
||||
frame.src = "/dom/nodes/ParentNode-querySelector-All-content.html#target";
|
||||
document.body.appendChild(frame);
|
||||
});
|
||||
|
||||
function init(e) {
|
||||
/*
|
||||
* This test suite tests Selectors API methods in 4 different contexts:
|
||||
* 1. Document node
|
||||
* 2. In-document Element node
|
||||
* 3. Detached Element node (an element with no parent, not in the document)
|
||||
* 4. Document Fragment node
|
||||
*
|
||||
* For each context, the following tests are run:
|
||||
*
|
||||
* The interface check tests ensure that each type of node exposes the Selectors API methods.
|
||||
*
|
||||
* The matches() tests are run
|
||||
* All the selectors tested for both the valid and invalid selector tests are found in selectors.js.
|
||||
* See comments in that file for documentation of the format used.
|
||||
*
|
||||
* The level2-lib.js file contains all the common test functions for running each of the aforementioned tests
|
||||
*/
|
||||
|
||||
var method = "webkitMatchesSelector";
|
||||
|
||||
var docType = "html"; // Only run tests suitable for HTML
|
||||
|
||||
// Prepare the nodes for testing
|
||||
var doc = e.target.contentDocument; // Document Node tests
|
||||
|
||||
var element = doc.getElementById("root"); // In-document Element Node tests
|
||||
|
||||
//Setup the namespace tests
|
||||
setupSpecialElements(doc, element);
|
||||
|
||||
var outOfScope = element.cloneNode(true); // Append this to the body before running the in-document
|
||||
// Element tests, but after running the Document tests. This
|
||||
// tests that no elements that are not descendants of element
|
||||
// are selected.
|
||||
|
||||
traverse(outOfScope, function(elem) { // Annotate each element as being a clone; used for verifying
|
||||
elem.setAttribute("data-clone", ""); // that none of these elements ever match.
|
||||
});
|
||||
|
||||
|
||||
var detached = element.cloneNode(true); // Detached Element Node tests
|
||||
|
||||
var fragment = doc.createDocumentFragment(); // Fragment Node tests
|
||||
fragment.appendChild(element.cloneNode(true));
|
||||
|
||||
// Setup Tests
|
||||
interfaceCheckMatches(method, "Document", doc);
|
||||
interfaceCheckMatches(method, "Detached Element", detached);
|
||||
interfaceCheckMatches(method, "Fragment", fragment);
|
||||
interfaceCheckMatches(method, "In-document Element", element);
|
||||
|
||||
runSpecialMatchesTests(method, "DIV Element", element);
|
||||
runSpecialMatchesTests(method, "NULL Element", document.createElement("null"));
|
||||
runSpecialMatchesTests(method, "UNDEFINED Element", document.createElement("undefined"));
|
||||
|
||||
runInvalidSelectorTestMatches(method, "Document", doc, invalidSelectors);
|
||||
runInvalidSelectorTestMatches(method, "Detached Element", detached, invalidSelectors);
|
||||
runInvalidSelectorTestMatches(method, "Fragment", fragment, invalidSelectors);
|
||||
runInvalidSelectorTestMatches(method, "In-document Element", element, invalidSelectors);
|
||||
|
||||
runMatchesTest(method, "In-document", doc, validSelectors, "html");
|
||||
runMatchesTest(method, "Detached", detached, validSelectors, "html");
|
||||
runMatchesTest(method, "Fragment", fragment, validSelectors, "html");
|
||||
|
||||
runMatchesTest(method, "In-document", doc, scopedSelectors, "html");
|
||||
}
|
||||
</script>
|
|
@ -32,7 +32,15 @@ isDefaultNamespace(frag, '', true, 'DocumentFragment is in default namespace, pr
|
|||
isDefaultNamespace(frag, 'foo', false, 'DocumentFragment is in default namespace, prefix "foo"');
|
||||
isDefaultNamespace(frag, 'xmlns', false, 'DocumentFragment is in default namespace, prefix "xmlns"');
|
||||
|
||||
|
||||
var docType = document.doctype;
|
||||
lookupNamespaceURI(docType, null, null, 'DocumentType should have null nemspace, prefix null');
|
||||
lookupNamespaceURI(docType, '', null, 'DocumentType should have null namespace, prefix ""');
|
||||
lookupNamespaceURI(docType, 'foo', null, 'DocumentType should have null namespace, prefix "foo"');
|
||||
lookupNamespaceURI(docType, 'xmlns', null, 'DocumentType should have null namespace, prefix "xmlns"');
|
||||
isDefaultNamespace(docType, null, true, 'DocumentType is in default namespace, prefix null');
|
||||
isDefaultNamespace(docType, '', true, 'DocumentType is in default namespace, prefix ""');
|
||||
isDefaultNamespace(docType, 'foo', false, 'DocumentType is in default namespace, prefix "foo"');
|
||||
isDefaultNamespace(docType, 'xmlns', false, 'DocumentType is in default namespace, prefix "xmlns"');
|
||||
|
||||
var fooElem = document.createElementNS('fooNamespace', 'prefix:elem');
|
||||
fooElem.setAttribute('bar', 'value');
|
||||
|
|
|
@ -444,6 +444,30 @@ test(function() {
|
|||
assert_equals(el3.getAttribute("foo"), "bar");
|
||||
}, "Basic functionality of setAttributeNode")
|
||||
|
||||
test(function() {
|
||||
var el = document.createElement("div");
|
||||
var attr1 = document.createAttributeNS("ns1", "p1:name");
|
||||
attr1.value = "value1";
|
||||
var attr2 = document.createAttributeNS("ns2", "p2:name");
|
||||
attr2.value = "value2";
|
||||
el.setAttributeNode(attr1);
|
||||
el.setAttributeNode(attr2);
|
||||
assert_equals(el.getAttributeNodeNS("ns1", "name").value, "value1");
|
||||
assert_equals(el.getAttributeNodeNS("ns2", "name").value, "value2");
|
||||
}, "setAttributeNode should distinguish attributes with same local name and different namespaces")
|
||||
|
||||
test(function() {
|
||||
var el = document.createElement("div");
|
||||
var attr1 = document.createAttributeNS("ns1", "p1:name");
|
||||
attr1.value = "value1";
|
||||
var attr2 = document.createAttributeNS("ns1", "p1:NAME");
|
||||
attr2.value = "VALUE2";
|
||||
el.setAttributeNode(attr1);
|
||||
el.setAttributeNode(attr2);
|
||||
assert_equals(el.getAttributeNodeNS("ns1", "name").value, "value1");
|
||||
assert_equals(el.getAttributeNodeNS("ns1", "NAME").value, "VALUE2");
|
||||
}, "setAttributeNode doesn't have case-insensitivity even with an HTMLElement")
|
||||
|
||||
test(function() {
|
||||
var el = document.createElement("div")
|
||||
el.setAttributeNS("x", "foo", "bar")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue