Update web-platform-tests to revision bda2059150dca8ab47f088b4cc619fcdc1f262fa

This commit is contained in:
Ms2ger 2016-05-30 09:58:25 +02:00
parent 3535f3f6c2
commit 7c4281f3da
182 changed files with 7692 additions and 1042 deletions

View file

@ -0,0 +1,89 @@
<!doctype html>
<meta charset=utf-8>
<title>Check how allowfullscreen affects fullscreen enabled flag</title>
<link rel="author" title="Xidorn Quan" href="https://www.upsuper.org">
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
<link rel="help" href="https://html.spec.whatwg.org/multipage/browsers.html#initialise-the-document-object">
<link rel="help" href="https://fullscreen.spec.whatwg.org/#fullscreen-enabled-flag">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function test_allowfullscreen(t, setup_iframe) {
var iframe = document.createElement("iframe");
setup_iframe(iframe);
iframe.src = "support/blank.htm";
var eventWatcher = new EventWatcher(t, iframe, "load");
document.body.appendChild(iframe);
t.add_cleanup(function() {
document.body.removeChild(iframe);
});
assert_true(document.fullscreenEnabled, "Top level document has fullscreen enabled flag set");
eventWatcher.wait_for("load").then(t.step_func(function() {
assert_false(iframe.contentDocument.fullscreenEnabled, "Document inside iframe without allowfullscreen attribute should not have fullscreen enabled flag set");
iframe.setAttribute("allowfullscreen", true);
assert_false(iframe.contentDocument.fullscreenEnabled, "Setting allowfullscreen attribute after document load should not affect fullscreen enabled flag");
iframe.contentWindow.location.reload();
return eventWatcher.wait_for("load");
})).then(t.step_func(function() {
assert_true(iframe.contentDocument.fullscreenEnabled, "Fullscreen enabled flag should be set when a new document is loaded with allowfullscreen attribute present");
iframe.removeAttribute("allowfullscreen");
assert_true(iframe.contentDocument.fullscreenEnabled, "Removing allowfullscreen attribute should not affect fullscreen enabled flag");
iframe.contentWindow.location.reload();
return eventWatcher.wait_for("load");
})).then(t.step_func_done(function() {
assert_false(iframe.contentDocument.fullscreenEnabled, "Fullscreen enabled flag should be reset when a new document is loaded with allowfullscreen attribute absent");
}));
}
async_test(function(t) {
test_allowfullscreen(t, function(iframe) {});
}, "iframe-allowfullscreen");
async_test(function(t) {
test_allowfullscreen(t, function(iframe) {
iframe.setAttribute("sandbox", "allow-same-origin");
});
}, "iframe-sandbox-allowfullscreen");
function test_allowfullscreen_dialog(t, setup_iframe, check) {
var iframe = document.createElement("iframe");
setup_iframe(iframe);
iframe.src = "support/blank.htm";
var eventWatcher = new EventWatcher(t, iframe, "load");
document.body.appendChild(iframe);
t.add_cleanup(function() {
document.body.removeChild(iframe);
});
var newWin;
assert_true(document.fullscreenEnabled, "Top level document has fullscreen enabled flag set");
eventWatcher.wait_for("load").then(t.step_func(function() {
assert_false(iframe.contentDocument.fullscreenEnabled, "Document inside iframe without allowfullscreen attribute should not have fullscreen enabled flag set");
newWin = iframe.contentWindow.open("support/blank.htm");
t.add_cleanup(function() {
newWin.close();
});
var newWinEventWatcher = new EventWatcher(t, newWin, "load");
return newWinEventWatcher.wait_for("load");
})).then(t.step_func_done(function() {
check(newWin);
}));
}
async_test(function(t) {
test_allowfullscreen_dialog(t, function() {}, function(newWin) {
assert_true(newWin.document.fullscreenEnabled, "Document in the new window is a top level document, thus should has fullscreen enabled flag set");
});
}, "iframe-allowfullscreen-dialog");
async_test(function(t) {
test_allowfullscreen_dialog(t, function(iframe) {
iframe.setAttribute("sandbox", "allow-same-origin allow-popups");
}, function(newWin) {
assert_false(newWin.document.fullscreenEnabled, "Document in the new window should inherit the sandboxed fullscreen flag and should not have fullscreen enabled flag set");
});
}, "iframe-sandbox-allowfullscreen-dialog");
</script>

View file

@ -0,0 +1,25 @@
<!doctype html>
<meta charset=utf-8>
<title>Check that popups from a sandboxed iframe escape the sandbox if
allow-popups-to-escape-sandbox is used</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<iframe sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox">
</iframe>
<script>
var t = async_test();
var ourOrigin;
onmessage = t.step_func(function(e) {
assert_equals(e.data, "hello", "This is our origin getter message");
ourOrigin = e.origin;
onmessage = t.step_func_done(function(e) {
assert_equals(e.origin, "null", "It came from a sandboxed iframe");
assert_equals(e.data.data, undefined, "Should have the right message");
assert_equals(e.data.origin, ourOrigin, "Should have escaped the sandbox");
});
document.querySelector("iframe").src = "iframe_sandbox_popups_helper.html";
});
postMessage("hello", "*");
</script>

View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<script>
var popupWin;
if (opener) {
// We're the popup. Send back our state. What we really want to send is
// our origin, but that will come automatically.
opener.postMessage(undefined, "*");
self.close();
} else {
// We're the child. Start listening for messages and open ourselves as the
// popup.
onmessage = function (e) {
parent.postMessage({ data: e.data, origin: e.origin }, "*");
};
popupWin = window.open(location.href);
}
</script>

View file

@ -0,0 +1,15 @@
<!doctype html>
<meta charset=utf-8>
<title>Check that popups from a sandboxed iframe do not escape the sandbox</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
var t = async_test();
onmessage = t.step_func_done(function(e) {
assert_equals(e.origin, "null", "It came from a sandboxed iframe");
assert_equals(e.data.data, undefined, "Should have the right message");
assert_equals(e.data.origin, "null", "Should not have escaped the sandbox");
});
</script>
<iframe sandbox="allow-scripts allow-popups"
src="iframe_sandbox_popups_helper.html"></iframe>

View file

@ -125,6 +125,8 @@
<img srcset='/images/green-1x1.png?e107 50w, /images/green-16x16.png?e107 51w' sizes='not ((min-width:0) or (unknown "general-enclosed")) 100vw, 1px'>
<img srcset='/images/green-1x1.png?e108 50w, /images/green-16x16.png?e108 51w' sizes='(max-width:0) or (unknown-general-enclosed !) 100vw, 1px'>
<img srcset='/images/green-1x1.png?e109 50w, /images/green-16x16.png?e109 51w' sizes='not ((max-width:0) or (unknown "general-enclosed")) 100vw, 1px'>
<img srcset='/images/green-1x1.png?f48 50w, /images/green-16x16.png?f48 51w' sizes='calc(1px'>
<img srcset='/images/green-1x1.png?f49 50w, /images/green-16x16.png?f49 51w' sizes='(min-width:0) calc(1px'>
<p>
<img srcset='/images/green-1x1.png?f1 50w, /images/green-16x16.png?f1 51w' sizes='100vw'>
@ -174,5 +176,3 @@
<img srcset='/images/green-1x1.png?f45 50w, /images/green-16x16.png?f45 51w' sizes='-1e0px'>
<img srcset='/images/green-1x1.png?f46 50w, /images/green-16x16.png?f46 51w' sizes='1e1.5px'>
<img srcset='/images/green-1x1.png?f47 50w, /images/green-16x16.png?f47 51w' style='--foo: 1px' sizes='var(--foo)'>
<img srcset='/images/green-1x1.png?f48 50w, /images/green-16x16.png?f48 51w' sizes='calc(1px'>
<img srcset='/images/green-1x1.png?f49 50w, /images/green-16x16.png?f49 51w' sizes='(min-width:0) calc(1px'>

View file

@ -99,6 +99,11 @@
}, "Check the checkValidity method of the form element when it has a fieldset child");
test(function(){
// Restore the condition to default which was modified during the previous test.
document.getElementById("fs").disabled = false;
document.getElementById("inp1").value = "";
document.getElementById("inp1").type = "text";
assert_true("reportValidity" in fm3, "The reportValidity method is not supported.");
assert_false(fm3.reportValidity(), "The reportValidity method should be false.");
document.getElementById("fs").disabled = true;

View file

@ -10,37 +10,88 @@
<p><fieldset id="fieldset">fieldset</fieldset>
<p><input id="input">
<p><keygen id="keygen">
<p><label id="label">label</label>
<p><object id="object">object</object>
<p><output id="output">output</output>
<p><select id="select"><option>select</option></select>
<p><textarea id="textarea">textarea</textarea>
<!-- label is special: label.form is an alias for label.control.form -->
<p><label id="label">label</label>
<p><label id="label-form" form="form">label-form</label>
<p><label id="label-form-form2" form="form2">label-form-form2</label>
<p><label id="label-with-control">label-with-control <input></label>
<p><label id="label-for" for="control-for-label">label-for</label> <input id="control-for-label">
<p><label id="label-with-progress">label-with-progress <progress></progress></label>
<p><label id="label-with-meter">label-with-meter <meter></meter></label>
<p>
<input id="input-with-form-attr-in-form" form="form2">
<label id="label-for-control-form-in-form" for="input-with-form-attr-in-form">label-for-control-form-in-form</label>
</p>
</form>
<form id="form2"></form>
<p>
<input id="input-with-form-attr" form="form2">
<label id="label-for-control-form" for="input-with-form-attr">label-for-control-form</label>
</p>
<!-- misnested tags where form-association is set by the HTML parser -->
<table>
<form id="form3"><!-- self-closes but sets the form element pointer -->
<tr>
<td><label id="label-in-table">label-in-table</label>
<td><label id="label-in-table-with-control">label-in-table <input></label>
<td><label id="label-in-table-for" for="input-in-table">label-in-table-for</label>
<td><input id="input-in-table"><!-- is associated with form3 -->
</tr>
</form>
</table>
<script>
var form;
setup(function() {
form = document.getElementById("form");
if (!form) {
throw new TypeError("Didn't find form");
form2 = document.getElementById("form2");
form3 = document.getElementById("form3");
if (!form || !form2 || !form3) {
throw new TypeError("Didn't find all forms");
}
});
var reassociateableElements = [
var listedElements = [
"button",
"fieldset",
"input",
"keygen",
"label",
"object",
"output",
"select",
"textarea",
];
reassociateableElements.forEach(function(localName) {
listedElements.forEach(function(localName) {
test(function() {
var button = document.getElementById(localName);
assert_equals(button.form, form);
var control = document.getElementById(localName);
assert_equals(control.form, form);
}, localName + ".form");
});
// label
function testLabel(id, expected) {
test(function() {
var label = document.getElementById(id);
assert_equals(label.control && label.control.form, expected, 'Sanity check: label.control.form');
assert_equals(label.form, expected, 'label.form');
}, id + ".form");
}
testLabel("label", null);
testLabel("label-form", null);
testLabel("label-form-form2", null);
testLabel("label-with-control", form);
testLabel("label-for", form);
testLabel("label-with-progress", null);
testLabel("label-with-meter", null);
testLabel("label-for-control-form-in-form", form2);
testLabel("label-for-control-form", form2);
testLabel("label-in-table", null);
testLabel("label-in-table-with-control", form3);
testLabel("label-in-table-for", form3);
</script>

View file

@ -34,6 +34,7 @@
c1_click_fired = true;
assert_false(c1_input_fired, "click event should fire before input event");
assert_false(c1_change_fired, "click event should fire before change event");
assert_false(e.isTrusted, "click()-initiated click event should not be trusted");
});
checkbox1.oninput = t1.step_func(function(e) {
c1_input_fired = true;

View file

@ -83,6 +83,7 @@
click_fired = true;
assert_false(input_fired, "click event should fire before input event");
assert_false(change_fired, "click event should fire before change event");
assert_false(e.isTrusted, "click()-initiated click event shouldn't be trusted");
});
radio5.oninput = t1.step_func(function(e) {
@ -90,7 +91,7 @@
assert_true(click_fired, "input event should fire after click event");
assert_false(change_fired, "input event should fire before change event");
assert_true(e.bubbles, "input event should bubble")
assert_false(e.isTrusted, "click()-initiated input event shouldn't be trusted");
assert_true(e.isTrusted, "input event should be trusted");
assert_false(e.cancelable, "input event should not be cancelable");
});
@ -99,7 +100,7 @@
assert_true(click_fired, "change event should fire after click event");
assert_true(input_fired, "change event should fire after input event");
assert_true(e.bubbles, "change event should bubble")
assert_false(e.isTrusted, "click()-initiated change event shouldn't be trusted");
assert_true(e.isTrusted, "change event should be trusted");
assert_false(e.cancelable, "change event should not be cancelable");
});

View file

@ -105,6 +105,8 @@ test(function() {
input.selectionStart = 0;
a = input.selectionEnd;
input.selectionEnd = 0;
a = input.selectionDirection;
input.selectionDirection = "none";
input.setSelectionRange(0, 0);
input.setRangeText('', 0, 0);
@ -118,10 +120,12 @@ test(function() {
input.type = type;
assert_equals(input.type, type, "the given input type is not supported");
assert_throws("INVALID_STATE_ERR", function() { var a = input.selectionStart; });
assert_equals(input.selectionStart, null, 'getting input.selectionStart');
assert_throws("INVALID_STATE_ERR", function() { input.selectionStart = 0; });
assert_throws("INVALID_STATE_ERR", function() { var a = input.selectionEnd; });
assert_equals(input.selectionEnd, null, 'getting input.selectionEnd');
assert_throws("INVALID_STATE_ERR", function() { input.selectionEnd = 0; });
assert_equals(input.selectionDirection, null, 'getting input.selectionDirection');
assert_throws("INVALID_STATE_ERR", function() { input.selectionDirection = "none"; });
assert_throws("INVALID_STATE_ERR", function() { input.setSelectionRange(0, 0); });
assert_throws("INVALID_STATE_ERR", function() { input.setRangeText('', 0, 0); });

View file

@ -121,14 +121,14 @@
// form attribute
test(function () {
assert_equals(document.getElementById("lbl0").form, document.getElementById("fm"),
"The 'form' property for a label with a form owner should return the form owner.");
}, "A label's form attribute should return its form owner.");
assert_equals(document.getElementById("lbl0").form, null,
"The 'form' property for a label should return null if label.control is null.");
}, "A label in a form without a control");
test(function () {
assert_equals(document.getElementById("lbl6").form, null,
"The 'form' property for a label without a form owner should return null.");
}, "Check that the labels property of a form control with no label returns a zero-length NodeList.");
assert_equals(document.getElementById("lbl6").form, document.getElementById("fm"),
"The 'form' property for a label should return label.control.form.");
}, "A label outside a form with a control inside the form");
// htmlFor attribute
test(function () {

View file

@ -30,14 +30,14 @@
</form>
<script>
testSelector(":checked", ["option1", "checkbox1", "radio1", "menuitem1", "menuitem4"], "':checked' matches checked <input>/<menuitem> in checkbox and radio button states, selected <option>s");
testSelectorIdsMatch(":checked", ["option1", "checkbox1", "radio1", "menuitem1", "menuitem4"], "':checked' matches checked <input>/<menuitem> in checkbox and radio button states, selected <option>s");
document.getElementById("checkbox1").removeAttribute("type"); // change type of input
document.getElementById("radio1").removeAttribute("type"); // change type of input
testSelector(":checked", ["option1", "menuitem1", "menuitem4"], "':checked' should no longer match <input>s whose type checkbox/radio has been removed");
testSelectorIdsMatch(":checked", ["option1", "menuitem1", "menuitem4"], "':checked' should no longer match <input>s whose type checkbox/radio has been removed");
document.getElementById("option2").selected = "selected"; // select option2
document.getElementById("checkbox2").click(); // check chekbox2
document.getElementById("radio2").click(); // check radio2
testSelector(":checked", ["option2", "checkbox2", "radio2", "menuitem1", "menuitem4"], "':checked' matches clicked checkbox and radio buttons");
testSelectorIdsMatch(":checked", ["option2", "checkbox2", "radio2", "menuitem1", "menuitem4"], "':checked' matches clicked checkbox and radio buttons");
</script>

View file

@ -56,9 +56,9 @@
<script>
testSelector(":default", ["button2", "button4", "input3", "input5", "input7", "checkbox1", "radio1", "option2", "button6", "button8"], "':default' matches <button>s that are their form's default button, <input>s of type submit/image that are their form's default button, checked <input>s and selected <option>s");
testSelectorIdsMatch(":default", ["button2", "button4", "input3", "input5", "input7", "checkbox1", "radio1", "option2", "button6", "button8"], "':default' matches <button>s that are their form's default button, <input>s of type submit/image that are their form's default button, checked <input>s and selected <option>s");
document.getElementById("button1").type = "submit"; // change the form's default button
testSelector(":default", ["button1", "button4", "input3", "input5", "input7", "checkbox1", "radio1", "option2", "button6", "button8"], "':default' matches dynamically changed form's default buttons");
testSelectorIdsMatch(":default", ["button1", "button4", "input3", "input5", "input7", "checkbox1", "radio1", "option2", "button6", "button8"], "':default' matches dynamically changed form's default buttons");
</script>

View file

@ -1,36 +1,46 @@
<!DOCTYPE html>
<meta charset=utf-8 id=meta>
<title id=title>Selector: pseudo-classes (:dir(ltr), :dir(rtl))</title>
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org" id=link1>
<link rel=help href="https://html.spec.whatwg.org/multipage/#pseudo-classes" id=link2>
<script src="/resources/testharness.js" id=script1></script>
<script src="/resources/testharnessreport.js" id=script2></script>
<script src="utils.js" id=script3></script>
<style id=style>
#span1 {direction: rtl;}
#span5, #span6 {display: none;}
</style>
<div id="log"></div>
<bdo dir="rtl" id=bdo1>WERBEH</bdo>
<bdo dir="ltr" id=bdo2>HEBREW</bdo>
<bdi id=bdi1>HEBREW</bdi>
<bdi dir="rtl" id=bdi2>WERBEH</bdi>
<bdi dir="ltr" id=bdi3>HEBREW</bdi>
<span id=span1>WERBEH</span>
<span dir="rtl" id=span2>WERBEH</span>
<span dir="ltr" id=span3>HEBREW</span>
&#x202E;<span id=span4>WERBEH</span>&#x202C;
<span dir="rtl" id=span5>WERBEH</span>
<span dir="ltr" id=span6>HEBREW</span>
<bdo dir="auto" id=bdo3>HEBREW</bdo>
<bdo dir="auto" id=bdo4>إيان</bdo>
<bdo dir="ltr" id=bdo5>עברית</bdo>
<html id=html>
<head id=head>
<meta charset=utf-8 id=meta>
<title id=title>Selector: pseudo-classes (:dir(ltr), :dir(rtl))</title>
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org" id=link1>
<link rel=help href="https://html.spec.whatwg.org/multipage/#pseudo-classes" id=link2>
<script src="/resources/testharness.js" id=script1></script>
<script src="/resources/testharnessreport.js" id=script2></script>
<script src="utils.js" id=script3></script>
<style id=style>
#span1 {direction: rtl;}
#span5, #span6 {display: none;}
</style>
</head>
<body id=body>
<div id="log"></div>
<bdo dir="rtl" id=bdo1>WERBEH</bdo>
<bdo dir="ltr" id=bdo2>HEBREW</bdo>
<bdi id=bdi1>HEBREW</bdi>
<bdi dir="rtl" id=bdi2>WERBEH</bdi>
<bdi dir="ltr" id=bdi3>HEBREW</bdi>
<bdi id=bdi4>إيان</bdi>
<span id=span1>WERBEH</span>
<span dir="rtl" id=span2>WERBEH</span>
<span dir="ltr" id=span3>HEBREW</span>
&#x202E;<span id=span4>WERBEH</span>&#x202C;
<span dir="rtl" id=span5>WERBEH</span>
<span dir="ltr" id=span6>HEBREW</span>
<bdo dir="auto" id=bdo3>HEBREW</bdo>
<bdo dir="auto" id=bdo4>إيان</bdo>
<bdo dir="ltr" id=bdo5>עברית</bdo>
<script>
testSelector(":dir(rtl)", ["bdo1", "bdi2", "span1", "span2", "span4", "span5", "bdo4"], "':dir(rtl)' matches all elements whose directionality is 'rtl'.");
testSelector(":dir(ltr)", ["html", "head", "body", "meta", "title", "link1", "link2", "script1", "script2", "script3", "stlyle", "log", "bdo2", "bdi3", "span3", "span6", "bdo3", "bdo5"], "':dir(ltr)' matches all elements whose directionality is 'ltr'.");
<script id=script4>
testSelectorIdsMatch(":dir(rtl)", ["bdo1", "bdi2", "bdi4", "span2", "span5", "bdo4"], "':dir(rtl)' matches all elements whose directionality is 'rtl'.");
var bdo = document.createElement("bdo");
bdo.setAttribute("dir", "ltr");
testSelector(":dir(ltr)", ["meta", "title", "link1", "link2", "script1", "script2", "script3", "stlyle", "log", "bdo2", "bdi3", "span3", "span6", "bdo3"], "':dir(ltr)' doesn't match elements not in the document.");
</script>
var ltrElements = ["html", "head", "meta", "title", "link1", "link2", "script1", "script2", "script3", "style", "body", "log", "bdo2", "bdi1", "bdi3", "span1", "span3", "span4", "span6", "bdo3", "bdo5", "script4"];
testSelectorIdsMatch(":dir(ltr)", ltrElements, "':dir(ltr)' matches all elements whose directionality is 'ltr'.");
var bdo = document.createElement("bdo");
bdo.setAttribute("dir", "ltr");
testSelectorIdsMatch(":dir(ltr)", ltrElements, "':dir(ltr)' doesn't match elements not in the document.");
</script>
</body>
</html>

View file

@ -14,5 +14,5 @@
var ltr = new Array(),
all = document.querySelectorAll('*');
for(var i = all.length; i--; ltr.unshift(all[i]));
testSelector(":dir(ltr)", ltr, "direction doesn't affect :dir()");
testSelectorElementsMatch(":dir(ltr)", ltr, "direction doesn't affect :dir()");
</script>

View file

@ -40,21 +40,21 @@
<progress disabled></progress>
<script>
testSelector(":disabled", ["button2", "input2", "select2", "optgroup2", "option2", "textarea2", "fieldset2", "clubname", "clubnum"], "':disabled' should match only disabled elements");
testSelectorIdsMatch(":disabled", ["button2", "input2", "select2", "optgroup2", "option2", "textarea2", "fieldset2", "clubname", "clubnum"], "':disabled' should match only disabled elements");
document.getElementById("button2").removeAttribute("disabled");
testSelector(":disabled", ["input2", "select2", "optgroup2", "option2", "textarea2", "fieldset2", "clubname", "clubnum"], "':disabled' should not match elements whose disabled attribute has been removed");
testSelectorIdsMatch(":disabled", ["input2", "select2", "optgroup2", "option2", "textarea2", "fieldset2", "clubname", "clubnum"], "':disabled' should not match elements whose disabled attribute has been removed");
document.getElementById("button1").setAttribute("disabled", "disabled");
testSelector(":disabled", ["button1", "input2", "select2", "optgroup2", "option2", "textarea2", "fieldset2", "clubname", "clubnum"], "':disabled' should also match elements whose disabled attribute has been set");
testSelectorIdsMatch(":disabled", ["button1", "input2", "select2", "optgroup2", "option2", "textarea2", "fieldset2", "clubname", "clubnum"], "':disabled' should also match elements whose disabled attribute has been set");
document.getElementById("button1").setAttribute("disabled", "disabled");
testSelector(":disabled", ["button1", "input2", "select2", "optgroup2", "option2", "textarea2", "fieldset2", "clubname", "clubnum"], "':disabled' should also match elements whose disabled attribute has been set twice");
testSelectorIdsMatch(":disabled", ["button1", "input2", "select2", "optgroup2", "option2", "textarea2", "fieldset2", "clubname", "clubnum"], "':disabled' should also match elements whose disabled attribute has been set twice");
document.getElementById("input2").setAttribute("type", "submit"); // change input type to submit
testSelector(":disabled", ["button1", "input2", "select2", "optgroup2", "option2", "textarea2", "fieldset2", "clubname", "clubnum"], "':disabled' should also match disabled elements whose type has changed");
testSelectorIdsMatch(":disabled", ["button1", "input2", "select2", "optgroup2", "option2", "textarea2", "fieldset2", "clubname", "clubnum"], "':disabled' should also match disabled elements whose type has changed");
var input = document.createElement("input");
input.setAttribute("disabled", "disabled");
testSelector(":disabled", ["button1", "input2", "select2", "optgroup2", "option2", "textarea2", "fieldset2", "clubname", "clubnum"], "':disabled' should not match elements not in the document");
testSelectorIdsMatch(":disabled", ["button1", "input2", "select2", "optgroup2", "option2", "textarea2", "fieldset2", "clubname", "clubnum"], "':disabled' should not match elements not in the document");
</script>

View file

@ -38,5 +38,5 @@
<fieldset disabled id=fieldset2></fieldset>
<script>
testSelector(":enabled", ["button1", "input1", "select1", "optgroup1", "option1", "textarea1", "submitbutton", "menuitem1", "fieldset1"], "':enabled' elements that are not disabled");
testSelectorIdsMatch(":enabled", ["button1", "input1", "select1", "optgroup1", "option1", "textarea1", "submitbutton", "menuitem1", "fieldset1"], "':enabled' elements that are not disabled");
</script>

View file

@ -16,24 +16,36 @@
<input type=radio id=radio1 checked>
<div tabindex=0 id=div1>hello</div>
<div contenteditable id=div2>content</div>
<iframe src="focus-iframe.html" id=iframe onload="load()"></iframe>
<iframe src="focus-iframe.html" id=iframe></iframe>
<script>
document.getElementById("input1").focus(); // set the focus on input1
testSelector(":focus", ["input1"], "input1 has the focus");
setup({explicit_done: true});
document.getElementById("div1").focus();
testSelector(":focus", ["div1"], "tabindex attribute makes the element focusable");
document.getElementById("div2").focus();
testSelector(":focus", ["div2"], "editable elements are focusable");
function load() {
document.getElementById("iframe").contentDocument.getElementById("inputiframe").focus();
testSelector(":focus", [], "':focus' doesn't match focused elements in iframe");
onload = function() {
if (document.hasFocus() || frames[0].document.hasFocus()) {
run_test()
} else {
window.onfocus = run_test;
}
}
document.body.focus();
testSelector(":focus", ["body"], "':focus' matches focussed body with tabindex");
function run_test() {
document.getElementById("input1").focus(); // set the focus on input1
testSelectorIdsMatch(":focus", ["input1"], "input1 has the focus");
document.getElementById("div1").focus();
testSelectorIdsMatch(":focus", ["div1"], "tabindex attribute makes the element focusable");
document.getElementById("div2").focus();
testSelectorIdsMatch(":focus", ["div2"], "editable elements are focusable");
document.body.focus();
testSelectorIdsMatch(":focus", ["body"], "':focus' matches focussed body with tabindex");
document.getElementById("iframe").contentDocument.getElementById("inputiframe").focus();
testSelectorIdsMatch(":focus", [], "':focus' doesn't match focused elements in iframe");
done();
}
</script>
</body>

View file

@ -18,20 +18,20 @@
<progress id="progress2" value=10></progress>
<script>
testSelector(":indeterminate", ["radio2", "radio3", "radio4", "radio5", "progress1"], "':progress' matches <input>s radio buttons whose radio button group contains no checked input and <progress> elements without value attribute");
testSelectorIdsMatch(":indeterminate", ["radio2", "radio3", "radio4", "radio5", "progress1"], "':progress' matches <input>s radio buttons whose radio button group contains no checked input and <progress> elements without value attribute");
document.getElementById("radio2").setAttribute("checked", "checked");
testSelector(":indeterminate", ["radio4", "radio5", "progress1"], "dynamically check a radio input in a radio button group");
testSelectorIdsMatch(":indeterminate", ["radio4", "radio5", "progress1"], "dynamically check a radio input in a radio button group");
document.getElementById("radio4").click();
testSelector(":indeterminate", ["checkbox1", "progress2"], "click on radio4 which is in the indeterminate state");
testSelectorIdsMatch(":indeterminate", ["checkbox1", "progress2"], "click on radio4 which is in the indeterminate state");
document.getElementById("progress1").setAttribute("value", "20");
testSelector(":indeterminate", [], "adding a value to progress1 should put it in a determinate state");
testSelectorIdsMatch(":indeterminate", [], "adding a value to progress1 should put it in a determinate state");
document.getElementById("progress2").removeAttribute("value");
testSelector(":indeterminate", ["progress2"], "removing progress2's value should put it in an indeterminate state");
testSelectorIdsMatch(":indeterminate", ["progress2"], "removing progress2's value should put it in an indeterminate state");
document.getElementById("checkbox1").indeterminate = true; // set checkbox1 in the indeterminate state
testSelector(":indeterminate", ["checkbox1", "progress2"], "':progress' also matches <input> checkbox whose indeterminate IDL is set to true");
testSelectorIdsMatch(":indeterminate", ["checkbox1", "progress2"], "':progress' also matches <input> checkbox whose indeterminate IDL is set to true");
</script>

View file

@ -70,15 +70,15 @@
<input min="1" value="0" type="reset">
<script>
testSelector(":in-range", ["number1", "datein", "timein", "weekin", "monthin", "datetimelocalin", "range0", "range1", "range2", "range3"], "':in-range' matches all elements that are candidates for constraint validation, have range limitations, and that are neither suffering from an underflow nor suffering from an overflow");
testSelectorIdsMatch(":in-range", ["number1", "datein", "timein", "weekin", "monthin", "datetimelocalin", "range0", "range1", "range2", "range3"], "':in-range' matches all elements that are candidates for constraint validation, have range limitations, and that are neither suffering from an underflow nor suffering from an overflow");
testSelector(":out-of-range", ["number3", "number4", "dateunder", "dateover", "timeunder", "timeover", "weekunder", "weekover", "monthunder", "monthover", "datetimelocalunder", "datetimelocalover"], "':out-of-range' matches all elements that are candidates for constraint validation, have range limitations, and that are either suffering from an underflow or suffering from an overflow");
testSelectorIdsMatch(":out-of-range", ["number3", "number4", "dateunder", "dateover", "timeunder", "timeover", "weekunder", "weekover", "monthunder", "monthover", "datetimelocalunder", "datetimelocalover"], "':out-of-range' matches all elements that are candidates for constraint validation, have range limitations, and that are either suffering from an underflow or suffering from an overflow");
document.getElementById("number1").value = -10;
testSelector(":in-range", ["datein", "timein", "weekin", "monthin", "datetimelocalin", "range0", "range1", "range2", "range3"], "':in-range' update number1's value < min");
testSelector(":out-of-range", ["number1", "number3", "number4", "dateunder", "dateover", "timeunder", "timeover", "weekunder", "weekover", "monthunder", "monthover", "datetimelocalunder", "datetimelocalover"], "':out-of-range' update number1's value < min");
testSelectorIdsMatch(":in-range", ["datein", "timein", "weekin", "monthin", "datetimelocalin", "range0", "range1", "range2", "range3"], "':in-range' update number1's value < min");
testSelectorIdsMatch(":out-of-range", ["number1", "number3", "number4", "dateunder", "dateover", "timeunder", "timeover", "weekunder", "weekover", "monthunder", "monthover", "datetimelocalunder", "datetimelocalover"], "':out-of-range' update number1's value < min");
document.getElementById("number3").min = 0;
testSelector(":in-range", ["number3", "datein", "timein", "weekin", "monthin", "datetimelocalin", "range0", "range1", "range2", "range3"], "':in-range' update number3's min < value");
testSelector(":out-of-range", ["number1", "number4", "dateunder", "dateover", "timeunder", "timeover", "weekunder", "weekover", "monthunder", "monthover", "datetimelocalunder", "datetimelocalover"], "':out-of-range' update number3's min < value");
testSelectorIdsMatch(":in-range", ["number3", "datein", "timein", "weekin", "monthin", "datetimelocalin", "range0", "range1", "range2", "range3"], "':in-range' update number3's min < value");
testSelectorIdsMatch(":out-of-range", ["number1", "number4", "dateunder", "dateover", "timeunder", "timeover", "weekunder", "weekover", "monthunder", "monthover", "datetimelocalunder", "datetimelocalover"], "':out-of-range' update number3's min < value");
</script>

View file

@ -16,8 +16,8 @@
<a href="http://[" id=link10></a>
<script>
testSelector(":link", ["link1", "link2", "link3", "link7", "link8", "link9", "link10"], "Only <a>s, <area>s and <link>s that have a href attribute match ':link'");
testSelectorIdsMatch(":link", ["link1", "link2", "link3", "link7", "link8", "link9", "link10"], "Only <a>s, <area>s and <link>s that have a href attribute match ':link'");
document.getElementById("link9").removeAttribute("href");
testSelector(":link", ["link1", "link2", "link3", "link7", "link8", "link10"], "':link' doesn't match elements whos href attribute has been removed");
testSelectorIdsMatch(":link", ["link1", "link2", "link3", "link7", "link8", "link10"], "':link' doesn't match elements whos href attribute has been removed");
</script>

View file

@ -45,45 +45,45 @@
</div>
<script>
testSelector("#set0 :read-write", [], "The :read-write pseudo-class must not match input elements to which the readonly attribute does not apply");
testSelectorIdsMatch("#set0 :read-write", [], "The :read-write pseudo-class must not match input elements to which the readonly attribute does not apply");
testSelector("#set0 :read-only", ["checkbox1", "hidden1", "range1", "color1", "radio1", "file1", "submit1", "image1", "button1", "reset1"], "The :read-only pseudo-class must match input elements to which the readonly attribute does not apply");
testSelectorIdsMatch("#set0 :read-only", ["checkbox1", "hidden1", "range1", "color1", "radio1", "file1", "submit1", "image1", "button1", "reset1"], "The :read-only pseudo-class must match input elements to which the readonly attribute does not apply");
testSelector("#set1 :read-write", ["input1"], "The :read-write pseudo-class must match input elements to which the readonly attribute applies, and that are mutable");
testSelectorIdsMatch("#set1 :read-write", ["input1"], "The :read-write pseudo-class must match input elements to which the readonly attribute applies, and that are mutable");
testSelector("#set1 :read-only", ["input2"], "The :read-only pseudo-class must not match input elements to which the readonly attribute applies, and that are mutable");
testSelectorIdsMatch("#set1 :read-only", ["input2"], "The :read-only pseudo-class must not match input elements to which the readonly attribute applies, and that are mutable");
document.getElementById("input1").setAttribute("readonly", "readonly");
testSelector("#set1 :read-write", [], "The :read-write pseudo-class must not match input elements after the readonly attribute has been added");
testSelectorIdsMatch("#set1 :read-write", [], "The :read-write pseudo-class must not match input elements after the readonly attribute has been added");
testSelector("#set1 :read-only", ["input1", "input2"], "The :read-only pseudo-class must match input elements after the readonly attribute has been added");
testSelectorIdsMatch("#set1 :read-only", ["input1", "input2"], "The :read-only pseudo-class must match input elements after the readonly attribute has been added");
document.getElementById("input1").removeAttribute("readonly");
testSelector("#set1 :read-write", ["input1"], "The :read-write pseudo-class must not match input elements after the readonly attribute has been removed");
testSelectorIdsMatch("#set1 :read-write", ["input1"], "The :read-write pseudo-class must not match input elements after the readonly attribute has been removed");
testSelector("#set1 :read-only", ["input2"], "The :read-only pseudo-class must match input elements after the readonly attribute has been removed");
testSelectorIdsMatch("#set1 :read-only", ["input2"], "The :read-only pseudo-class must match input elements after the readonly attribute has been removed");
testSelector("#set2 :read-write", ["textarea1"], "The :read-write pseudo-class must match textarea elements that do not have a readonly attribute, and that are not disabled");
testSelectorIdsMatch("#set2 :read-write", ["textarea1"], "The :read-write pseudo-class must match textarea elements that do not have a readonly attribute, and that are not disabled");
testSelector("#set2 :read-only", ["textarea2"], "The :read-only pseudo-class must match textarea elements that have a readonly attribute, or that are disabled");
testSelectorIdsMatch("#set2 :read-only", ["textarea2"], "The :read-only pseudo-class must match textarea elements that have a readonly attribute, or that are disabled");
document.getElementById("textarea1").setAttribute("readonly", "readonly");
testSelector("#set2 :read-write", [], "The :read-write pseudo-class must match textarea elements after the readonly attribute has been added");
testSelectorIdsMatch("#set2 :read-write", [], "The :read-write pseudo-class must match textarea elements after the readonly attribute has been added");
testSelector("#set2 :read-only", ["textarea1", "textarea2"], "The :read-only pseudo-class must match textarea elements after the readonly attribute has been added");
testSelectorIdsMatch("#set2 :read-only", ["textarea1", "textarea2"], "The :read-only pseudo-class must match textarea elements after the readonly attribute has been added");
testSelector("#set3 :read-write", ["textarea3"], "The :read-write pseudo-class must not match textarea elements that are disabled");
testSelectorIdsMatch("#set3 :read-write", ["textarea3"], "The :read-write pseudo-class must not match textarea elements that are disabled");
testSelector("#set3 :read-only", ["textarea4"], "The :read-only pseudo-class must match textarea elements that are disabled");
testSelectorIdsMatch("#set3 :read-only", ["textarea4"], "The :read-only pseudo-class must match textarea elements that are disabled");
testSelector("#set4 :read-write", ["p2"], "The :read-write pseudo-class must match elements that are editable");
testSelectorIdsMatch("#set4 :read-write", ["p2"], "The :read-write pseudo-class must match elements that are editable");
testSelector("#set4 :read-only", ["p1"], "The :read-only pseudo-class must not match elements that are editable");
testSelectorIdsMatch("#set4 :read-only", ["p1"], "The :read-only pseudo-class must not match elements that are editable");
document.designMode = "on";
testSelector("#set4 :read-write", ["p1", "p2"], "The :read-write pseudo-class must match elements that are editing hosts");
testSelectorIdsMatch("#set4 :read-write", ["p1", "p2"], "The :read-write pseudo-class must match elements that are editing hosts");
testSelector("#set4 :read-only", [], "The :read-only pseudo-class must not match elements that are editing hosts");
testSelectorIdsMatch("#set4 :read-only", [], "The :read-only pseudo-class must not match elements that are editing hosts");
</script>

View file

@ -22,14 +22,14 @@
<textarea id=textarea2>textarea2</textarea>
<script>
testSelector(":required", ["text1", "text2", "select1", "textarea1"], "':required' matches required <input>s, <select>s and <textarea>s");
testSelector(":optional", ["text3", "select2", "textarea2"], "':optional' matches elements <input>s, <select>s and <textarea>s that are not required");
testSelectorIdsMatch(":required", ["text1", "text2", "select1", "textarea1"], "':required' matches required <input>s, <select>s and <textarea>s");
testSelectorIdsMatch(":optional", ["text3", "select2", "textarea2"], "':optional' matches elements <input>s, <select>s and <textarea>s that are not required");
document.getElementById("text1").removeAttribute("required");
testSelector(":required", ["text2", "select1", "textarea1"], "':required' doesn't match elements whose required attribute has been removed");
testSelector(":optional", ["text1", "text3", "select2", "textarea2"], "':optional' matches elements whose required attribute has been removed");
testSelectorIdsMatch(":required", ["text2", "select1", "textarea1"], "':required' doesn't match elements whose required attribute has been removed");
testSelectorIdsMatch(":optional", ["text1", "text3", "select2", "textarea2"], "':optional' matches elements whose required attribute has been removed");
document.getElementById("select2").setAttribute("required", "required");
testSelector(":required", ["text2", "select1", "select2", "textarea1"], "':required' matches elements whose required attribute has been added");
testSelector(":optional", ["text1", "text3", "textarea2"], "':optional' doesn't match elements whose required attribute has been added");
testSelectorIdsMatch(":required", ["text2", "select1", "select2", "textarea1"], "':required' matches elements whose required attribute has been added");
testSelectorIdsMatch(":optional", ["text1", "text3", "textarea2"], "':optional' doesn't match elements whose required attribute has been added");
</script>

View file

@ -6,9 +6,15 @@ function getElementsByIds(ids) {
return result;
}
function testSelector(selector, expected, testName) {
function testSelectorIdsMatch(selector, ids, testName) {
test(function(){
var elements = document.querySelectorAll(selector);
assert_array_equals(elements, getElementsByIds(expected));
assert_array_equals(elements, getElementsByIds(ids));
}, testName);
}
function testSelectorElementsMatch(selector, elements, testName) {
test(function(){
assert_array_equals(document.querySelectorAll(selector), elements);
}, testName);
}

View file

@ -37,32 +37,32 @@
</div>
<script>
testSelector("#simpleConstraints :valid", ["text1"], "':valid' matches elements that satisfy their constraints");
testSelectorIdsMatch("#simpleConstraints :valid", ["text1"], "':valid' matches elements that satisfy their constraints");
testSelector("#FormSelection :valid", ["form1", "text3"], "':valid' matches form elements that are not the form owner of any elements that themselves are candidates for constraint validation but do not satisfy their constraints");
testSelectorIdsMatch("#FormSelection :valid", ["form1", "text3"], "':valid' matches form elements that are not the form owner of any elements that themselves are candidates for constraint validation but do not satisfy their constraints");
testSelector("#FieldSetSelection :valid", ["fieldset1", "text5"], "':valid' matches fieldset elements that have no descendant elements that themselves are candidates for constraint validation but do not satisfy their constraints");
testSelectorIdsMatch("#FieldSetSelection :valid", ["fieldset1", "text5"], "':valid' matches fieldset elements that have no descendant elements that themselves are candidates for constraint validation but do not satisfy their constraints");
testSelector("#patternConstraints :valid", [ "text8" ], "':valid' matches elements that satisfy their pattern constraints");
testSelectorIdsMatch("#patternConstraints :valid", [ "text8" ], "':valid' matches elements that satisfy their pattern constraints");
testSelector("#numberConstraints :valid", [ "number2" ], "':valid' matches elements that satisfy their number constraints");
testSelectorIdsMatch("#numberConstraints :valid", [ "number2" ], "':valid' matches elements that satisfy their number constraints");
testSelector("#simpleConstraints :invalid", ["text2"], "':invalid' matches elements that do not satisfy their simple text constraints");
testSelectorIdsMatch("#simpleConstraints :invalid", ["text2"], "':invalid' matches elements that do not satisfy their simple text constraints");
testSelector("#FormSelection :invalid", ["form2", "text4"], "':invalid' matches form elements that are the form owner of one or more elements that themselves are candidates for constraint validation but do not satisfy their constraints");
testSelectorIdsMatch("#FormSelection :invalid", ["form2", "text4"], "':invalid' matches form elements that are the form owner of one or more elements that themselves are candidates for constraint validation but do not satisfy their constraints");
testSelector("#FieldSetSelection :invalid", ["fieldset2", "text6"], "':invalid' matches fieldset elements that have of one or more descendant elements that themselves are candidates for constraint validation but do not satisfy their constraints");
testSelectorIdsMatch("#FieldSetSelection :invalid", ["fieldset2", "text6"], "':invalid' matches fieldset elements that have of one or more descendant elements that themselves are candidates for constraint validation but do not satisfy their constraints");
testSelector("#patternConstraints :invalid", ["text7"], "':invalid' matches elements that do not satisfy their pattern constraints");
testSelectorIdsMatch("#patternConstraints :invalid", ["text7"], "':invalid' matches elements that do not satisfy their pattern constraints");
testSelector("#numberConstraints :invalid", ["number1"], "':invalid' matches elements that do not satisfy their number constraints");
testSelectorIdsMatch("#numberConstraints :invalid", ["number1"], "':invalid' matches elements that do not satisfy their number constraints");
document.getElementById("text7").value="0BBB";
testSelector("#patternConstraints :valid", [ "text7", "text8" ], "':valid' matches new elements that satisfy their constraints");
testSelector("#patternConstraints :invalid", [], "':invalid' doesn't match new elements that satisfy their constraints");
testSelectorIdsMatch("#patternConstraints :valid", [ "text7", "text8" ], "':valid' matches new elements that satisfy their constraints");
testSelectorIdsMatch("#patternConstraints :invalid", [], "':invalid' doesn't match new elements that satisfy their constraints");
document.getElementById("text8").value="BBB";
testSelector("#patternConstraints :valid", ["text7"], "':valid' doesn't match new elements that do not satisfy their constraints");
testSelector("#patternConstraints :invalid", ["text8"], "':invalid' matches new elements that do not satisfy their constraints");
testSelectorIdsMatch("#patternConstraints :valid", ["text7"], "':valid' doesn't match new elements that do not satisfy their constraints");
testSelectorIdsMatch("#patternConstraints :invalid", ["text8"], "':invalid' matches new elements that do not satisfy their constraints");
</script>

View file

@ -34,6 +34,14 @@ function test_table_simple(group, table) {
assert_equals(table.rows.bar, bar1);
assert_equals(table.rows["bar"], bar1);
assert_equals(table.rows.namedItem("bar"), bar1);
assert_array_equals(Object.getOwnPropertyNames(table.rows), [
"0",
"1",
"2",
"3",
"foo",
"bar"
]);
}
test(function() {
var table = document.createElement("table");
@ -145,6 +153,46 @@ test(function() {
foot2row1,
foot2row2
]);
assert_array_equals(Object.getOwnPropertyNames(table.rows), [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"head1row1",
"head1row2",
"head2row1",
"head2row2",
"orphan1",
"orphan2",
"orphan3",
"body1row1",
"body1row2",
"orphan4",
"body2row1",
"body2row2",
"orphan5",
"orphan6",
"orphan7",
"foot1row1",
"foot1row2",
"foot2row1",
"foot2row2"
]);
var ids = [
"orphan1",