mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +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
tests/wpt/web-platform-tests/html/semantics/OWNERS
Normal file
1
tests/wpt/web-platform-tests/html/semantics/OWNERS
Normal file
|
@ -0,0 +1 @@
|
|||
@ayg
|
|
@ -29,14 +29,27 @@
|
|||
<div id="test" style="display:none">STYLING TEST</div>
|
||||
|
||||
<script>
|
||||
test(function() {
|
||||
var style = null,
|
||||
i;
|
||||
for (i = 1; i < 5; i++) {
|
||||
style = document.getElementById("style" + i);
|
||||
assert_equals(style.sheet, null, "The sheet attribute of style" + i + " should be null.");
|
||||
assert_false(style.disabled, "The disabled attribute of style" + i + " should be false.");
|
||||
}
|
||||
/**
|
||||
* Browsers may incorrectly issue requests for these resources and defer
|
||||
* definition of the `sheet` attribute until after loading is complete.
|
||||
* In such cases, synchronous assertions regarding the absence of
|
||||
* attributes will spuriously pass.
|
||||
*
|
||||
* In order to account for this incorrect behavior (exhibited at the time
|
||||
* of this writing most notably by the Chromium browser), defer the
|
||||
* assertions until the "load" event has been triggered.
|
||||
*/
|
||||
async_test(function(t) {
|
||||
window.addEventListener("load", t.step_func(function() {
|
||||
var style = null,
|
||||
i;
|
||||
for (i = 1; i < 5; i++) {
|
||||
style = document.getElementById("style" + i);
|
||||
assert_equals(style.sheet, null, "The sheet attribute of style" + i + " should be null.");
|
||||
assert_false(style.disabled, "The disabled attribute of style" + i + " should be false.");
|
||||
}
|
||||
t.done();
|
||||
}));
|
||||
}, "The LinkStyle interface's sheet attribute must return null; the disabled attribute must be false");
|
||||
|
||||
test(function() {
|
||||
|
@ -46,14 +59,17 @@
|
|||
assert_equals(link.sheet, null, "The sheet attribute of the link element not in a document should be null.");
|
||||
}, "The LinkStyle interface's sheet attribute must return null if the corresponding element is not in a Document");
|
||||
|
||||
test(function() {
|
||||
var style = null,
|
||||
i;
|
||||
for (i = 5; i < 8; i++) {
|
||||
style = document.getElementById("style" + i);
|
||||
assert_true(style.sheet instanceof StyleSheet, "The sheet attribute of style" + i + " should be a StyleSheet object.");
|
||||
assert_equals(style.disabled, style.sheet.disabled, "The disabled attribute of style" + i + " should equal to the same attribute of StyleSheet.");
|
||||
}
|
||||
async_test(function(t) {
|
||||
window.addEventListener("load", t.step_func(function() {
|
||||
var style = null,
|
||||
i;
|
||||
for (i = 5; i < 8; i++) {
|
||||
style = document.getElementById("style" + i);
|
||||
assert_true(style.sheet instanceof StyleSheet, "The sheet attribute of style" + i + " should be a StyleSheet object.");
|
||||
assert_equals(style.disabled, style.sheet.disabled, "The disabled attribute of style" + i + " should equal to the same attribute of StyleSheet.");
|
||||
}
|
||||
t.done();
|
||||
}));
|
||||
}, "The LinkStyle interface's sheet attribute must return StyleSheet object; the disabled attribute must be same as the StyleSheet's disabled attribute");
|
||||
|
||||
test(function() {
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<html>
|
||||
<head>
|
||||
<style>
|
||||
iframe { width: 400px; height: 300px;}
|
||||
</style>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({explicit_timeout: true});
|
||||
|
||||
async_test(function(t) {
|
||||
window.addEventListener("message", t.step_func_done(function(e) {
|
||||
assert_equals(e.data, "BLOCKED", "The message should say 'BLOCKED'.");
|
||||
}));
|
||||
}, "The sandboxed iframe should post a message saying the top navigation was blocked when no user gesture.");
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p>This tests that an iframe in sandbox with 'allow-top-navigation-by-user-activation'
|
||||
can navigate the top level page, if it is trigged by a user gesture.</p>
|
||||
<p>Click on the button in the iframe and it should navigate the top page.</p>
|
||||
<iframe id="i" sandbox="allow-scripts allow-top-navigation-by-user-activation" src="support/iframe-that-performs-top-navigation.html"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,19 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
window.addEventListener("message", t.step_func_done(function(e) {
|
||||
assert_equals(e.data, "PASS", "The message should say 'PASS' instead of 'FAIL'");
|
||||
}));
|
||||
}, "The sandboxed iframe should post a message saying the test was in the state of 'PASS'.");
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p>This tests that an iframe in sandbox with 'allow-top-navigation-by-user-activation'
|
||||
cannot navigate its top level page, if it is not trigged by a user gesture.</p>
|
||||
<iframe sandbox='allow-top-navigation-by-user-activation allow-scripts' src="support/iframe-that-performs-top-navigation-without-user-gesture-failed.html"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,16 @@
|
|||
<html>
|
||||
<body>
|
||||
The top navigation from this iframe should be blocked. This text should appear.
|
||||
<script>
|
||||
window.onload = function()
|
||||
{
|
||||
try {
|
||||
top.location = "navigation-changed-iframe.html";
|
||||
top.postMessage("FAIL", "*");
|
||||
} catch(e) {
|
||||
top.postMessage("PASS", "*");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,20 @@
|
|||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function performTest()
|
||||
{
|
||||
try {
|
||||
top.location = "navigation-changed-iframe.html";
|
||||
} catch(e) {
|
||||
top.postMessage("BLOCKED", "*");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="performTest();">
|
||||
<p>This doc tried to navigate the top page when loaded, which should fail since it's not trigged by user activation while in a sandboxed frame with 'allow-top-navigtaion-by-user-activation'. <br> <br>
|
||||
Click the button below, the top navigation should succeed with a new page saying "PASSED: Navigation succeeded." in browsers supporting the 'allow-top-navigtaion-by-user-activation' iframe@sandbox keyword (eg., Chrome v58+); Otherwise, the top navigation should fail.
|
||||
</p>
|
||||
<button id="b" onclick="performTest();">Navigate the top page</button>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,14 @@
|
|||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function fireSentinel()
|
||||
{
|
||||
document.getElementsByTagName('h4')[0].innerHTML = document.domain;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="fireSentinel();">
|
||||
<h4>DOMAIN</h4>
|
||||
<p>PASSED: Navigation succeeded.</p>
|
||||
</body>
|
||||
</html>
|
|
@ -26,4 +26,12 @@
|
|||
assert_true((new Image()).namespaceURI === "http://www.w3.org/1999/xhtml");
|
||||
}, "Image namespace URI is correct");
|
||||
|
||||
test(function() {
|
||||
assert_equals(Image.name, "Image", "Image name should be Image (not HTMLImageElement)");
|
||||
assert_equals(Image.__proto__, Function.prototype, "Image __proto__ is Function prototype");
|
||||
assert_equals(Image.prototype, HTMLImageElement.prototype, "Image.prototype is same as HTMLImageElement.prototype");
|
||||
assert_equals(new Image().__proto__, HTMLImageElement.prototype, "Image __proto__ is HTMLImageElement prototype ");
|
||||
assert_equals(Image.prototype.__proto__, HTMLElement.prototype, "Image.prototype __proto__ is HTMLElement prototype");
|
||||
}, "NamedConstructor creates the correct object structure.");
|
||||
|
||||
</script>
|
||||
|
|
|
@ -1,45 +1,84 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<meta name="timeout" content="long">
|
||||
<title>text field selection: select()</title>
|
||||
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
<link rel=help href="https://html.spec.whatwg.org/multipage/#textFieldSelection">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
|
||||
<textarea>foobar</textarea>
|
||||
<input type="text" value="foobar">
|
||||
<input type="search" value="foobar">
|
||||
<input type="tel" value="1234">
|
||||
<input type="url" value="https://example.com/">
|
||||
<input type="password" value="hunter2">
|
||||
|
||||
<script>
|
||||
var input_types = ["text", "search", "tel", "url", "password"],
|
||||
t1 = async_test("select() on textarea queues select event"),
|
||||
q1 = false;
|
||||
"use strict";
|
||||
|
||||
input_types.forEach(function(type) {
|
||||
var input = document.createElement("input"),
|
||||
t = async_test("select() on input type " + type + " queues select event"),
|
||||
q = false;
|
||||
t.step(function() {
|
||||
input.type = type;
|
||||
input.value = "foobar";
|
||||
document.body.appendChild(input);
|
||||
input.onselect = t.step_func_done(function(e) {
|
||||
assert_true(q, "event should be queued");
|
||||
assert_true(e.isTrusted, "event is trusted");
|
||||
assert_true(e.bubbles, "event bubbles");
|
||||
assert_false(e.cancelable, "event is not cancelable");
|
||||
const els = [document.querySelector("textarea"), ...document.querySelectorAll("input")];
|
||||
|
||||
const actions = [
|
||||
{
|
||||
label: "select()",
|
||||
action: el => el.select()
|
||||
},
|
||||
{
|
||||
label: "selectionStart",
|
||||
action: el => el.selectionStart = 1
|
||||
},
|
||||
{
|
||||
label: "selectionEnd",
|
||||
action: el => el.selectionEnd = el.value.length - 1
|
||||
},
|
||||
{
|
||||
label: "selectionDirection",
|
||||
action: el => el.selectionDirection = "backward"
|
||||
},
|
||||
{
|
||||
label: "setSelectionRange()",
|
||||
action: el => el.setSelectionRange(1, el.value.length - 1) // changes direction implicitly to none/forward
|
||||
},
|
||||
{
|
||||
label: "setRangeText()",
|
||||
action: el => el.setRangeText("newmiddle")
|
||||
}
|
||||
];
|
||||
|
||||
for (const el of els) {
|
||||
const elLabel = el.localName === "textarea" ? "textarea" : "input type " + el.type;
|
||||
|
||||
for (const action of actions) {
|
||||
// promise_test instead of async_test is important because these need to happen in sequence (to test that events
|
||||
// fire if and only if the selection changes).
|
||||
promise_test(t => {
|
||||
const watcher = new EventWatcher(t, el, "select");
|
||||
|
||||
const promise = watcher.wait_for("select").then(e => {
|
||||
assert_true(e.isTrusted, "isTrusted must be true");
|
||||
assert_true(e.bubbles, "bubbles must be true");
|
||||
assert_false(e.cancelable, "cancelable must be false");
|
||||
});
|
||||
input.select();
|
||||
q=true;
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelector("textarea").onselect = t1.step_func_done(function(e) {
|
||||
assert_true(q1, "event should be queued");
|
||||
assert_true(e.isTrusted, "event is trusted");
|
||||
assert_true(e.bubbles, "event bubbles");
|
||||
assert_false(e.cancelable, "event is not cancelable");
|
||||
});
|
||||
action.action(el);
|
||||
|
||||
t1.step(function() {
|
||||
document.querySelector("textarea").select();
|
||||
q1=true;
|
||||
});
|
||||
return promise;
|
||||
}, `${elLabel}: ${action.label}`);
|
||||
|
||||
promise_test(t => {
|
||||
el.onselect = t.unreached_func("the select event must not fire the second time");
|
||||
|
||||
action.action(el);
|
||||
|
||||
return new Promise(resolve => {
|
||||
t.step_timeout(() => {
|
||||
el.onselect = null;
|
||||
resolve();
|
||||
}, 200);
|
||||
});
|
||||
}, `${elLabel}: ${action.label} a second time (must not fire select)`);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -14,14 +14,17 @@
|
|||
test(function(){
|
||||
var el = document.createElement("input");
|
||||
el.type = type;
|
||||
assert_equals(el.selectionStart, null);
|
||||
assert_equals(el.selectionEnd, null);
|
||||
assert_equals(el.selectionDirection, null);
|
||||
assert_throws("InvalidStateError", function(){
|
||||
el.selectionStart;
|
||||
el.selectionStart = 0;
|
||||
});
|
||||
assert_throws("InvalidStateError", function(){
|
||||
el.selectionEnd;
|
||||
el.selectionEnd = 0;
|
||||
});
|
||||
assert_throws("InvalidStateError", function(){
|
||||
el.selectionDirection;
|
||||
el.selectionDirection = 'none';
|
||||
});
|
||||
assert_throws("InvalidStateError", function(){
|
||||
el.setRangeText("foobar");
|
||||
|
|
|
@ -0,0 +1,148 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title></title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
function createInputElement(value, append, suffix) {
|
||||
var el = document.createElement("input");
|
||||
el.type = "text";
|
||||
el.value = value;
|
||||
el.id = "input" + (append ? "-appended" : "-not-appended") + (suffix ? suffix : "");
|
||||
if (append) {
|
||||
document.body.appendChild(el);
|
||||
}
|
||||
return el;
|
||||
};
|
||||
|
||||
function createTextareaElement(value, append, suffix) {
|
||||
var el = document.createElement("textarea");
|
||||
el.value = value;
|
||||
|
||||
el.id = "textarea" + (append ? "-appended" : "-not-appended") + (suffix ? suffix : "");
|
||||
if (append) {
|
||||
document.body.appendChild(el);
|
||||
}
|
||||
return el;
|
||||
};
|
||||
|
||||
function createPrefocusedInputElement(value, append) {
|
||||
var el = createInputElement(value, append, "-prefocused");
|
||||
el.focus();
|
||||
el.blur();
|
||||
return el;
|
||||
}
|
||||
|
||||
function createPrefocusedTextareaElement(value, append) {
|
||||
var el = createTextareaElement(value, append, "-prefocused");
|
||||
el.focus();
|
||||
el.blur();
|
||||
return el;
|
||||
}
|
||||
|
||||
function createTestElements(value) {
|
||||
return [ createInputElement(value, true),
|
||||
createInputElement(value, false),
|
||||
createPrefocusedInputElement(value, true),
|
||||
createPrefocusedInputElement(value, false),
|
||||
createTextareaElement(value, true),
|
||||
createTextareaElement(value, false),
|
||||
createPrefocusedTextareaElement(value, true),
|
||||
createPrefocusedTextareaElement(value, false),
|
||||
];
|
||||
}
|
||||
|
||||
var testValue = "abcdefghij";
|
||||
|
||||
test(function() {
|
||||
assert_equals(testValue.length, 10);
|
||||
}, "Sanity check for testValue length; if this fails, variou absolute offsets in the test below need to be adjusted to be less than testValue.length");
|
||||
|
||||
test(function() {
|
||||
for (let el of createTestElements(testValue)) {
|
||||
assert_equals(el.selectionStart, testValue.length,
|
||||
`Initial .value set on ${el.id} should set selectionStart to end of value`);
|
||||
var t = async_test(`onselect should fire when selectionStart is changed on ${el.id}`);
|
||||
el.onselect = t.step_func_done(function(e) {
|
||||
assert_equals(e.type, "select");
|
||||
el.remove();
|
||||
});
|
||||
el.selectionStart = 2;
|
||||
}
|
||||
}, "onselect should fire when selectionStart is changed");
|
||||
|
||||
test(function() {
|
||||
for (let el of createTestElements(testValue)) {
|
||||
assert_equals(el.selectionEnd, testValue.length,
|
||||
`Initial .value set on ${el.id} should set selectionEnd to end of value`);
|
||||
var t = async_test(`onselect should fire when selectionEnd is changed on ${el.id}`);
|
||||
el.onselect = t.step_func_done(function(e) {
|
||||
assert_equals(e.type, "select");
|
||||
el.remove();
|
||||
});
|
||||
el.selectionEnd = 2;
|
||||
}
|
||||
}, "onselect should fire when selectionEnd is changed");
|
||||
|
||||
test(function() {
|
||||
for (let el of createTestElements(testValue)) {
|
||||
assert_equals(el.selectionStart, testValue.length,
|
||||
`Initial .value set on ${el.id} should set selectionStart to end of value`);
|
||||
el.selectionStart = 0;
|
||||
el.selectionEnd = 5;
|
||||
el.selectionStart = 8;
|
||||
assert_equals(el.selectionStart, 8, `selectionStart on ${el.id}`);
|
||||
assert_equals(el.selectionEnd, 8, `selectionEnd on ${el.id}`);
|
||||
el.remove();
|
||||
}
|
||||
}, "Setting selectionStart to a value larger than selectionEnd should increase selectionEnd");
|
||||
|
||||
test(function() {
|
||||
for (let el of createTestElements(testValue)) {
|
||||
assert_equals(el.selectionStart, testValue.length,
|
||||
`Initial .value set on ${el.id} should set selectionStart to end of value`);
|
||||
assert_equals(el.selectionEnd, testValue.length,
|
||||
`Initial .value set on ${el.id} should set selectionEnd to end of value`);
|
||||
el.selectionStart = 8;
|
||||
el.selectionEnd = 5;
|
||||
assert_equals(el.selectionStart, 5, `selectionStart on ${el.id}`);
|
||||
assert_equals(el.selectionEnd, 5, `selectionEnd on ${el.id}`);
|
||||
el.remove();
|
||||
}
|
||||
}, "Setting selectionEnd to a value smaller than selectionStart should decrease selectionStart");
|
||||
|
||||
test(function() {
|
||||
for (let el of createTestElements(testValue)) {
|
||||
el.selectionStart = 0;
|
||||
assert_equals(el.selectionStart, 0, `We just set it on ${el.id}`);
|
||||
el.selectionStart = -1;
|
||||
assert_equals(el.selectionStart, testValue.length,
|
||||
`selectionStart setter on ${el.id} should convert -1 to 2^32-1`);
|
||||
el.selectionStart = Math.pow(2, 32);
|
||||
assert_equals(el.selectionStart, 0,
|
||||
`selectionStart setter on ${el.id} should convert 2^32 to 0`);
|
||||
el.selectionStart = Math.pow(2, 32) - 1;
|
||||
assert_equals(el.selectionStart, testValue.length,
|
||||
`selectionStart setter on ${el.id} should leave 2^32-1 as-is`);
|
||||
el.remove();
|
||||
}
|
||||
}, "selectionStart edge-case values");
|
||||
|
||||
test(function() {
|
||||
for (let el of createTestElements(testValue)) {
|
||||
el.selectionEnd = 0;
|
||||
assert_equals(el.selectionEnd, 0, `We just set it on ${el.id}`);
|
||||
el.selectionEnd = -1;
|
||||
assert_equals(el.selectionEnd, testValue.length,
|
||||
`selectionEnd setter on ${el.id} should convert -1 to 2^32-1`);
|
||||
el.selectionEnd = Math.pow(2, 32);
|
||||
assert_equals(el.selectionEnd, 0,
|
||||
`selectionEnd setter on ${el.id} should convert 2^32 to 0`);
|
||||
el.selectionEnd = Math.pow(2, 32) - 1;
|
||||
assert_equals(el.selectionEnd, testValue.length,
|
||||
`selectionEnd setter on ${el.id} should leave 2^32-1 as-is`);
|
||||
el.remove();
|
||||
}
|
||||
}, "selectionEnd edge-case values");
|
||||
</script>
|
|
@ -0,0 +1,95 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title></title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div id=log></div>
|
||||
<div id=target></div>
|
||||
<script>
|
||||
var target = document.getElementById("target");
|
||||
var sometext = "something";
|
||||
var shorttext = "abc";
|
||||
var elemData = [
|
||||
{
|
||||
desc: "textarea not in body",
|
||||
factory: () => document.createElement("textarea"),
|
||||
},
|
||||
{
|
||||
desc: "input not in body",
|
||||
factory: () => document.createElement("input"),
|
||||
},
|
||||
{
|
||||
desc: "textarea in body",
|
||||
factory: () => document.body.appendChild(document.createElement("textarea")),
|
||||
},
|
||||
{
|
||||
desc: "input in body",
|
||||
factory: () => document.body.appendChild(document.createElement("input")),
|
||||
},
|
||||
{
|
||||
desc: "textarea in body with parsed default value",
|
||||
factory: () => {
|
||||
target.innerHTML = "<textarea>abcdefghij</textarea>"
|
||||
return target.querySelector("textarea");
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "input in body with parsed default value",
|
||||
factory: () => {
|
||||
target.innerHTML = "<input value='abcdefghij'>"
|
||||
return target.querySelector("input");
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "focused textarea",
|
||||
factory: () => {
|
||||
var t = document.body.appendChild(document.createElement("textarea"));
|
||||
t.focus();
|
||||
return t;
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "focused input",
|
||||
factory: () => {
|
||||
var i = document.body.appendChild(document.createElement("input"));
|
||||
i.focus();
|
||||
return i;
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "focused then blurred textarea",
|
||||
factory: () => {
|
||||
var t = document.body.appendChild(document.createElement("textarea"));
|
||||
t.focus();
|
||||
t.blur();
|
||||
return t;
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "focused then blurred input",
|
||||
factory: () => {
|
||||
var i = document.body.appendChild(document.createElement("input"));
|
||||
i.focus();
|
||||
i.blur()
|
||||
return i;
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
for (var data of elemData) {
|
||||
test(function() {
|
||||
var el = data.factory();
|
||||
this.add_cleanup(() => el.remove());
|
||||
el.defaultValue = sometext;
|
||||
assert_true(sometext.length > 8,
|
||||
"sometext too short, test won't work right");
|
||||
el.selectionStart = 4;
|
||||
el.selectionEnd = 6;
|
||||
el.setRangeText("xyz");
|
||||
el.defaultValue = "set range text";
|
||||
assert_equals(el.value, sometext.slice(0, 4) + "xyz" + sometext.slice(6),
|
||||
"Calling setRangeText should set the value dirty flag");
|
||||
}, `value dirty flag behavior after setRangeText on ${data.desc}`);
|
||||
}
|
||||
|
||||
</script>
|
|
@ -14,18 +14,24 @@
|
|||
var dirs = ['forward', 'backward', 'none'];
|
||||
var sampleText = "0123456789";
|
||||
|
||||
var createInputElement = function(value) {
|
||||
var createInputElement = function(value, append = true) {
|
||||
var el = document.createElement("input");
|
||||
el.type = "text";
|
||||
el.value = value;
|
||||
body.appendChild(el);
|
||||
el.id = "input" + (append ? "-appended" : "-not-appended");
|
||||
if (append) {
|
||||
body.appendChild(el);
|
||||
}
|
||||
return el;
|
||||
};
|
||||
|
||||
var createTextareaElement = function(value) {
|
||||
var createTextareaElement = function(value, append = true) {
|
||||
var el = document.createElement("textarea");
|
||||
el.value = value;
|
||||
body.appendChild(el);
|
||||
el.id = "textarea" + (append ? "-appended" : "-not-appended");
|
||||
if (append) {
|
||||
body.appendChild(el);
|
||||
}
|
||||
return el;
|
||||
};
|
||||
|
||||
|
@ -82,49 +88,74 @@
|
|||
}, "test if non-ascii selection text is correct for textarea");
|
||||
|
||||
|
||||
test(function() {
|
||||
var el = createInputElement(sampleText);
|
||||
// If there is no selection, then it must return the offset(in logical order)
|
||||
// to the character that immediately follows the text entry cursor.
|
||||
assert_equals(el.selectionStart, el.value.length, "SelectionStart offset without selection");
|
||||
el.select();
|
||||
assert_equals(el.selectionStart, 0, "SelectionStart offset");
|
||||
el.parentNode.removeChild(el);
|
||||
}, "test SelectionStart offset for input");
|
||||
for (var append of [true, false]) {
|
||||
test(function() {
|
||||
var el = createInputElement(sampleText, append);
|
||||
// If there is no selection, then it must return the offset(in logical order)
|
||||
// to the character that immediately follows the text entry cursor.
|
||||
assert_equals(el.selectionStart, el.value.length,
|
||||
"SelectionStart offset without selection in " + el.id);
|
||||
if (!el.parentNode) {
|
||||
return;
|
||||
}
|
||||
el.select();
|
||||
assert_equals(el.selectionStart, 0, "SelectionStart offset");
|
||||
el.parentNode.removeChild(el);
|
||||
}, "test SelectionStart offset for input that is " +
|
||||
(append ? "appended" : " not appended"));
|
||||
}
|
||||
|
||||
for (var append of [true, false]) {
|
||||
test(function() {
|
||||
var el = createTextareaElement(sampleText, append);
|
||||
// If there is no selection, then it must return the offset(in logical order)
|
||||
// to the character that immediately follows the text entry cursor.
|
||||
assert_equals(el.selectionStart, el.value.length,
|
||||
"SelectionStart offset without selection in " + el.id);
|
||||
if (!el.parentNode) {
|
||||
return;
|
||||
}
|
||||
el.select();
|
||||
assert_equals(el.selectionStart, 0, "SelectionStart offset");
|
||||
el.parentNode.removeChild(el);
|
||||
}, "test SelectionStart offset for textarea that is " +
|
||||
(append ? "appended" : " not appended"));
|
||||
}
|
||||
|
||||
for (var append of [true, false]) {
|
||||
test(function() {
|
||||
var el = createInputElement(sampleText, append);
|
||||
// If there is no selection, then it must return the offset(in logical order)
|
||||
// to the character that immediately follows the text entry cursor.
|
||||
assert_equals(el.selectionEnd, el.value.length,
|
||||
"SelectionEnd offset without selection in " + el.id);
|
||||
if (!el.parentNode) {
|
||||
return;
|
||||
}
|
||||
el.select();
|
||||
assert_equals(el.selectionEnd, el.value.length, "SelectionEnd offset");
|
||||
el.parentNode.removeChild(el);
|
||||
}, "test SelectionEnd offset for input that is " +
|
||||
(append ? "appended" : " not appended"));
|
||||
}
|
||||
|
||||
|
||||
test(function() {
|
||||
var el = createTextareaElement(sampleText);
|
||||
// If there is no selection, then it must return the offset(in logical order)
|
||||
// to the character that immediately follows the text entry cursor.
|
||||
assert_equals(el.selectionStart, el.value.length, "SelectionStart offset without selection");
|
||||
el.select();
|
||||
assert_equals(el.selectionStart, 0, "SelectionStart offset");
|
||||
el.parentNode.removeChild(el);
|
||||
}, "test SelectionStart offset for textarea");
|
||||
|
||||
|
||||
test(function() {
|
||||
var el = createInputElement(sampleText);
|
||||
// If there is no selection, then it must return the offset(in logical order)
|
||||
// to the character that immediately follows the text entry cursor.
|
||||
assert_equals(el.selectionEnd, el.value.length, "SelectionEnd offset without selection");
|
||||
el.select();
|
||||
assert_equals(el.selectionEnd, el.value.length, "SelectionEnd offset");
|
||||
el.parentNode.removeChild(el);
|
||||
}, "test SelectionEnd offset for input");
|
||||
|
||||
|
||||
test(function() {
|
||||
var el = createTextareaElement(sampleText);
|
||||
// If there is no selection, then it must return the offset(in logical order)
|
||||
// to the character that immediately follows the text entry cursor.
|
||||
assert_equals(el.selectionEnd, el.value.length, "SelectionEnd offset without selection");
|
||||
el.select();
|
||||
assert_equals(el.selectionEnd, el.value.length, "SelectionEnd offset");
|
||||
el.parentNode.removeChild(el);
|
||||
}, "test SelectionEnd offset for textarea");
|
||||
|
||||
for (var append of [true, false]) {
|
||||
test(function() {
|
||||
var el = createTextareaElement(sampleText, append);
|
||||
// If there is no selection, then it must return the offset(in logical order)
|
||||
// to the character that immediately follows the text entry cursor.
|
||||
assert_equals(el.selectionEnd, el.value.length,
|
||||
"SelectionEnd offset without selection in " + el.id);
|
||||
if (!el.parentNode) {
|
||||
return;
|
||||
}
|
||||
el.select();
|
||||
assert_equals(el.selectionEnd, el.value.length, "SelectionEnd offset");
|
||||
el.parentNode.removeChild(el);
|
||||
}, "test SelectionEnd offset for textarea that is " +
|
||||
(append ? "appended" : " not appended"));
|
||||
}
|
||||
|
||||
test(function() {
|
||||
var el = createInputElement(sampleText);
|
||||
|
|
|
@ -106,15 +106,24 @@
|
|||
}, element.id + " setRangeText without argument throws a type error");
|
||||
|
||||
async_test(function() {
|
||||
var q = false;
|
||||
element.onselect = this.step_func_done(function(e) {
|
||||
assert_true(q, "event should be queued");
|
||||
assert_true(e.isTrusted, "event is trusted");
|
||||
assert_true(e.bubbles, "event bubbles");
|
||||
assert_false(e.cancelable, "event is not cancelable");
|
||||
});
|
||||
element.setRangeText("foobar2", 0, 6);
|
||||
q = true;
|
||||
// At this point there are already "select" events queued up on
|
||||
// "element". Give them time to fire; otherwise we can get spurious
|
||||
// passes.
|
||||
//
|
||||
// This is unfortunately racy in that we might _still_ get spurious
|
||||
// passes. I'm not sure how best to handle that.
|
||||
setTimeout(this.step_func(function() {
|
||||
var q = false;
|
||||
element.onselect = this.step_func_done(function(e) {
|
||||
assert_true(q, "event should be queued");
|
||||
assert_true(e.isTrusted, "event is trusted");
|
||||
assert_true(e.bubbles, "event bubbles");
|
||||
assert_false(e.cancelable, "event is not cancelable");
|
||||
});
|
||||
element.setRangeText("foobar2", 0, 6);
|
||||
q = true;
|
||||
}), 10);
|
||||
}, element.id + " setRangeText fires a select event");
|
||||
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -138,6 +138,22 @@ test(function() {
|
|||
assert_equals(input.selectionStart, 0, "element.selectionStart should be 0");
|
||||
assert_equals(input.selectionEnd, 1, "element.selectionEnd should be 1");
|
||||
},'input setSelectionRange(undefined,1)');
|
||||
|
||||
test(function() {
|
||||
input.setSelectionRange(Math.pow(2,32) - 2, Math.pow(2,32) - 1);
|
||||
assert_equals(input.selectionStart, input.value.length,
|
||||
"element.selectionStart should be value.length");
|
||||
assert_equals(input.selectionEnd, input.value.length,
|
||||
"element.selectionEnd should be value.length");
|
||||
}, 'input setSelectionRange(Math.pow(2,32) - 2, Math.pow(2,32) - 1)');
|
||||
|
||||
test(function() {
|
||||
input.setSelectionRange(Math.pow(2,31), Math.pow(2,32) - 1);
|
||||
assert_equals(input.selectionStart, input.value.length,
|
||||
"element.selectionStart should be value.length");
|
||||
assert_equals(input.selectionEnd, input.value.length,
|
||||
"element.selectionEnd should be value.length");
|
||||
}, 'input setSelectionRange(Math.pow(2,31), Math.pow(2,32) - 1)');
|
||||
},"test of input.setSelectionRange");
|
||||
|
||||
async_test(function() {
|
||||
|
@ -257,18 +273,21 @@ test(function() {
|
|||
assert_equals(textarea.selectionStart, 0, "element.selectionStart should be 0");
|
||||
assert_equals(textarea.selectionEnd, 1, "element.selectionStart should be 1");
|
||||
},'textarea setSelectionRange(undefined,1)');
|
||||
},"test of textarea.setSelectionRange");
|
||||
|
||||
async_test(function() {
|
||||
var q = false;
|
||||
var textarea = document.getElementById("b");
|
||||
textarea.addEventListener("select", this.step_func_done(function(e) {
|
||||
assert_true(q, "event should be queued");
|
||||
assert_true(e.isTrusted, "event is trusted");
|
||||
assert_true(e.bubbles, "event bubbles");
|
||||
assert_false(e.cancelable, "event is not cancelable");
|
||||
}));
|
||||
textarea.setSelectionRange(0, 1);
|
||||
q = true;
|
||||
}, "textarea setSelectionRange fires a select event");
|
||||
test(function() {
|
||||
textarea.setSelectionRange(Math.pow(2,32) - 2, Math.pow(2,32) - 1);
|
||||
assert_equals(textarea.selectionStart, textarea.value.length,
|
||||
"element.selectionStart should be value.length");
|
||||
assert_equals(textarea.selectionEnd, textarea.value.length,
|
||||
"element.selectionEnd should be value.length");
|
||||
}, 'textarea setSelectionRange(Math.pow(2,32) - 2, Math.pow(2,32) - 1)');
|
||||
|
||||
test(function() {
|
||||
textarea.setSelectionRange(Math.pow(2,31), Math.pow(2,32) - 1);
|
||||
assert_equals(textarea.selectionStart, textarea.value.length,
|
||||
"element.selectionStart should be value.length");
|
||||
assert_equals(textarea.selectionEnd, textarea.value.length,
|
||||
"element.selectionEnd should be value.length");
|
||||
}, 'textarea setSelectionRange(Math.pow(2,31), Math.pow(2,32) - 1)');
|
||||
},"test of textarea.setSelectionRange");
|
||||
</script>
|
||||
|
|
|
@ -96,4 +96,22 @@ test(function () {
|
|||
|
||||
}, "Setting element by index should correctly append and replace elements");
|
||||
|
||||
test(function () {
|
||||
var selection = document.createElementNS("http://www.w3.org/1999/xhtml", "foo:select");
|
||||
|
||||
selection.length = 5;
|
||||
assert_equals(selection.length, 5,
|
||||
"Number of nodes in collection should have changed");
|
||||
for (var i = 0; i < 5; ++i) {
|
||||
var child = selection.children[i];
|
||||
assert_equals(child.localName, "option",
|
||||
"new child should be an option");
|
||||
assert_equals(child.namespaceURI, "http://www.w3.org/1999/xhtml",
|
||||
"new child should be an HTML element");
|
||||
assert_equals(child.prefix, null,
|
||||
"new child should not copy select's prefix");
|
||||
}
|
||||
|
||||
}, "Changing the length adds new nodes; The new nodes will not copy select's prefix");
|
||||
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML contextmenu event is a MouseEvent</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<style>#contextmenutarget { width: 100px; height: 100px; background-color: red; }</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='contextmenutarget'>Trigger context menu in this box.</div>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
var t = async_test('contextmenu event generated from user action is MouseEvent');
|
||||
document.querySelector("#contextmenutarget").addEventListener('contextmenu', t.step_func(function (e) {
|
||||
assert_equals(e.constructor, window.MouseEvent);
|
||||
document.querySelector("#contextmenutarget").style.backgroundColor = "green";
|
||||
t.done();
|
||||
}));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>dialog element centered frame</title>
|
||||
<style>
|
||||
html {
|
||||
writing-mode: {{GET[html-writing-mode]}}
|
||||
}
|
||||
|
||||
#container {
|
||||
writing-mode: {{GET[container-writing-mode]}}
|
||||
}
|
||||
|
||||
dialog {
|
||||
writing-mode: {{GET[dialog-writing-mode]}};
|
||||
border: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="container">
|
||||
<dialog style="width: 20px; height: 10px;">X</dialog> <!-- sync width and height with centering.html -->
|
||||
</div>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
document.querySelector("dialog").showModal();
|
||||
</script>
|
|
@ -0,0 +1,51 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>dialog element: centered alignment</title>
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
<link rel=help href="https://html.spec.whatwg.org/multipage/#centered-alignment">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
// Be sure to sync with centering-iframe.html
|
||||
const DIALOG_WIDTH = 20;
|
||||
const DIALOG_HEIGHT = 10;
|
||||
|
||||
testDialogCentering("horizontal-tb", "", "", "tall viewport", 40, 100, "top", 100 / 2 - DIALOG_HEIGHT / 2);
|
||||
testDialogCentering("horizontal-tb", "", "", "wide viewport", 100, 40, "top", 40 / 2 - DIALOG_HEIGHT / 2);
|
||||
testDialogCentering("horizontal-tb", "", "", "square viewport", 100, 100, "top", 100 / 2 - DIALOG_HEIGHT / 2);
|
||||
testDialogCentering("horizontal-tb", "", "", "dialog and viewport match", DIALOG_WIDTH, DIALOG_HEIGHT, "top", 0);
|
||||
testDialogCentering("horizontal-tb", "", "", "dialog bigger than viewport", 100, DIALOG_HEIGHT / 2, "top", 0);
|
||||
|
||||
testDialogCentering("vertical-rl", "", "", "tall viewport", 40, 100, "left", 40 / 2 - DIALOG_WIDTH / 2);
|
||||
testDialogCentering("vertical-lr", "", "", "tall viewport", 40, 100, "right", 40 / 2 - DIALOG_WIDTH / 2);
|
||||
testDialogCentering("vertical-lr", "", "", "dialog bigger than viewport", DIALOG_WIDTH / 2, 100, "right", 0);
|
||||
|
||||
testDialogCentering("vertical-rl", "", "horizontal-tb", "tall viewport", 40, 100, "left", 40 / 2 - DIALOG_WIDTH / 2);
|
||||
testDialogCentering("vertical-lr", "", "horizontal-tb", "tall viewport", 40, 100, "right", 40 / 2 - DIALOG_WIDTH / 2);
|
||||
testDialogCentering("vertical-lr", "", "horizontal-tb", "dialog bigger than viewport", DIALOG_WIDTH / 2, 100, "right", 0);
|
||||
|
||||
testDialogCentering("horizontal-tb", "vertical-rl", "", "tall viewport", 40, 100, "right", 40 / 2 - DIALOG_WIDTH / 2);
|
||||
testDialogCentering("vertical-rl", "horizontal-tb", "", "tall viewport", 40, 100, "top", 100 / 2 - DIALOG_HEIGHT / 2);
|
||||
|
||||
testDialogCentering("horizontal-tb", "vertical-rl", "horizontal-tb", "tall viewport", 40, 100, "right", 40 / 2 - DIALOG_WIDTH / 2);
|
||||
testDialogCentering("vertical-rl", "horizontal-tb", "vertical-rl", "tall viewport", 40, 100, "top", 100 / 2 - DIALOG_HEIGHT / 2);
|
||||
|
||||
function testDialogCentering(writingMode, containerWritingMode, dialogWritingMode, label, iframeWidth, iframeHeight, property, numericValue) {
|
||||
async_test(t => {
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.src = `centering-iframe.sub.html?html-writing-mode=${writingMode}&container-writing-mode=${containerWritingMode}&dialog-writing-mode=${dialogWritingMode}`;
|
||||
iframe.width = iframeWidth;
|
||||
iframe.height = iframeHeight;
|
||||
iframe.onload = t.step_func_done(() => {
|
||||
const dialog = iframe.contentDocument.querySelector("dialog");
|
||||
assert_equals(iframe.contentWindow.getComputedStyle(dialog)[property], numericValue + "px");
|
||||
});
|
||||
document.body.appendChild(iframe);
|
||||
}, writingMode + (containerWritingMode ? ` (container ${containerWritingMode})` : "") +
|
||||
(dialogWritingMode ? ` (dialog ${dialogWritingMode})` : "") + `: ${label}`);
|
||||
}
|
||||
</script>
|
|
@ -2,6 +2,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>html-script-module-execOrder</title>
|
||||
<meta name=timeout content=long>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
|
|
|
@ -54,4 +54,12 @@ test(function() {
|
|||
t.tFoot = document.createElement("thead");
|
||||
});
|
||||
})
|
||||
|
||||
test(function () {
|
||||
var table = document.createElementNS("http://www.w3.org/1999/xhtml", "foo:table")
|
||||
var tfoot = table.createTFoot();
|
||||
|
||||
assert_equals(table.tFoot, tfoot);
|
||||
assert_equals(tfoot.prefix, null);
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -63,4 +63,12 @@ test(function() {
|
|||
t2.tHead = t2thead;
|
||||
});
|
||||
});
|
||||
|
||||
test(function () {
|
||||
var table = document.createElementNS("http://www.w3.org/1999/xhtml", "foo:table")
|
||||
var thead = table.createTHead();
|
||||
|
||||
assert_equals(table.tHead, thead);
|
||||
assert_equals(thead.prefix, null);
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -52,4 +52,13 @@ test(function () {
|
|||
});
|
||||
}, "HTMLTableRowElement insertCell(cells.length + 1)");
|
||||
|
||||
test(function () {
|
||||
var table = document.createElementNS("http://www.w3.org/1999/xhtml", "foo:table")
|
||||
var row = table.insertRow(0);
|
||||
var cell = row.insertCell(0);
|
||||
|
||||
assert_equals(row.cells[0], cell);
|
||||
assert_equals(cell.prefix, null);
|
||||
}, "HTMLTableRowElement insertCell will not copy table's prefix");
|
||||
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue