mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Update web-platform-tests to revision e426a6933a05bf144eba06a1d4c47ba876a4e2d1
This commit is contained in:
parent
415b26e4f1
commit
5e5eccabf8
495 changed files with 14920 additions and 784 deletions
|
@ -15,7 +15,7 @@ async_test(function(t) {
|
|||
assert_equals(cues[1].startTime, 31);
|
||||
assert_equals(cues[2].startTime, 61);
|
||||
assert_equals(cues.getCueById("4").startTime, 121);
|
||||
assert_object_equals(cues.getCueById("junk"), undefined);
|
||||
assert_equals(cues.getCueById("junk"), null);
|
||||
|
||||
// Create a new cue, check values.
|
||||
var textCue = new VTTCue(33, 3.4, "Sausage?");
|
||||
|
|
|
@ -13,7 +13,7 @@ async_test(function(t) {
|
|||
|
||||
// Register the 'addtrack' listener after creating the element
|
||||
// to make sure the event is dispatched asynchronously.
|
||||
video.textTracks.onaddtrack = t.step_func(function() {
|
||||
video.textTracks.onaddtrack = t.step_func(function(event) {
|
||||
assert_equals(event.target, video.textTracks);
|
||||
assert_true(event instanceof TrackEvent, 'instanceof');
|
||||
assert_equals(event.track, tracks[video.textTracks.length - 1]);
|
||||
|
@ -31,4 +31,4 @@ async_test(function(t) {
|
|||
assert_equals(video.textTracks.length, 1);
|
||||
assert_equals(trackElement.readyState, HTMLTrackElement.NONE);
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -34,13 +34,21 @@
|
|||
|
||||
video.src = getVideoURI("/media/test");
|
||||
video.play();
|
||||
|
||||
// Wait for end of first cue (no events should fire while track is disabled).
|
||||
t.step_timeout(testHiddenAndShowing, 400);
|
||||
video.ontimeupdate = () => {
|
||||
if (video.currentTime > 0.4) {
|
||||
testHiddenAndShowing();
|
||||
video.ontimeupdate = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
track.oncuechange = t.step_func(function(event) {
|
||||
cueCount++;
|
||||
if (cueCount == textTrack.cues.length)
|
||||
// As the 'enter' and the 'exit' event would be fired for the second
|
||||
// and the third cue, so there would be 4 times 'oncuechange' event.
|
||||
if (cueCount == 4)
|
||||
t.done();
|
||||
});
|
||||
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
"id": "autofocusing-a-form-control-the-autofocus-attribute",
|
||||
"original_id": "autofocusing-a-form-control:-the-autofocus-attribute"
|
||||
},
|
||||
{
|
||||
"id": "input-modalities-the-enterkeyhint-attribute",
|
||||
"original_id": "input-modalities:-the-enterkeyhint-attribute"
|
||||
},
|
||||
{
|
||||
"id": "input-modalities-the-inputmode-attribute",
|
||||
"original_id": "input-modalities:-the-inputmode-attribute"
|
||||
|
@ -31,4 +35,4 @@
|
|||
"id": "autofilling-form-controls-the-autocomplete-attribute",
|
||||
"original_id": "autofilling-form-controls:-the-autocomplete-attribute"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
|
|
@ -18,8 +18,39 @@ test(() => {
|
|||
assert_equals(counter, 2);
|
||||
}, 'If constructing entry list flag of form is true, then return');
|
||||
|
||||
let test10 = async_test('Cannot navigate (after constructing the entry list)');
|
||||
test10.step(() => {
|
||||
|
||||
test(() => {
|
||||
let form = populateForm('<input required><input type=submit><button type=submit></button>');
|
||||
let submitter1 = form.querySelector('input[type=submit]');
|
||||
let submitter2 = form.querySelector('button[type=submit]');
|
||||
let invalid = form.querySelector('[required]');
|
||||
let counter = 0;
|
||||
invalid.oninvalid = () => {
|
||||
++counter;
|
||||
// Needs to click different one because click() has reentrancy protection.
|
||||
submitter2.click();
|
||||
};
|
||||
submitter1.click();
|
||||
assert_equals(counter, 1);
|
||||
}, "If form's firing submission events is true, then return; 'invalid' event");
|
||||
|
||||
async_test(t => {
|
||||
let form = populateForm('<input type=submit name=n value=i><button type=submit name=n value=b>');
|
||||
let submitter1 = form.querySelector('input[type=submit]');
|
||||
let submitter2 = form.querySelector('button[type=submit]');
|
||||
let iframe = form.previousSibling;
|
||||
form.onsubmit = () => {
|
||||
// Needs to click different one because click() has reentrancy protection.
|
||||
submitter2.click();
|
||||
};
|
||||
submitter1.click();
|
||||
// We actually submit the form in order to check which 'click()' submits it.
|
||||
iframe.onload = t.step_func_done(() => {
|
||||
assert_not_equals(iframe.contentWindow.location.search.indexOf('n=i'), -1);
|
||||
});
|
||||
}, "If form's firing submission events is true, then return; 'submit' event");
|
||||
|
||||
async_test(t => {
|
||||
let form = populateForm('<input name=n1 value=v1>');
|
||||
form.onformdata = (e) => { e.target.remove(); };
|
||||
let wasLoaded = false;
|
||||
|
@ -27,13 +58,13 @@ test10.step(() => {
|
|||
// Request to load '/common/dummy.xhtml', and immediately submit the form to
|
||||
// the same frame. If the form submission is aborted, the first request
|
||||
// will be completed.
|
||||
iframe.onload = test10.step_func_done(() => {
|
||||
iframe.onload = t.step_func_done(() => {
|
||||
wasLoaded = true;
|
||||
assert_true(iframe.contentWindow.location.search.indexOf('n1=v1') == -1);
|
||||
});
|
||||
iframe.src = '/common/dummy.xhtml';
|
||||
assert_false(wasLoaded, 'Make sure the first loading is ongoing.');
|
||||
form.submit();
|
||||
});
|
||||
}, 'Cannot navigate (after constructing the entry list)');
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -11,3 +11,11 @@ function populateForm(optionalContentHtml) {
|
|||
++frameCounter;
|
||||
return document.body.firstChild.nextSibling;
|
||||
}
|
||||
|
||||
function submitPromise(form, iframe) {
|
||||
return new Promise((resolve, reject) => {
|
||||
iframe.onload = () => resolve(iframe.contentWindow.location.search);
|
||||
iframe.onerror = () => reject(new Error('iframe onerror fired'));
|
||||
form.submit();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
<!DOCTYPE html>
|
||||
<title>form.requestSubmit() tests</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<iframe name="iframe" src="about:blank"></iframe>
|
||||
|
||||
<script>
|
||||
test(() => {
|
||||
document.body.insertAdjacentHTML('afterbegin', '<form>' +
|
||||
'<input type="reset">' +
|
||||
'<input type="text">' +
|
||||
'<button type="reset"></button>' +
|
||||
'<button type="button"></button>' +
|
||||
'</form>');
|
||||
let form = document.querySelector('form');
|
||||
assert_throws(new TypeError(), () => {
|
||||
form.requestSubmit(document.body);
|
||||
});
|
||||
for (let control of form.elements) {
|
||||
assert_throws(new TypeError(), () => { form.requestSubmit(control); });
|
||||
}
|
||||
}, 'Passing an element which is not a submit button should throw');
|
||||
|
||||
test(() => {
|
||||
document.body.insertAdjacentHTML('afterbegin', `<form>
|
||||
<input form="" type="submit">
|
||||
<button form="form2" type="submit"></button>
|
||||
</form>
|
||||
<form id="form2"></form>`);
|
||||
let form = document.querySelector('form');
|
||||
let submitButton = document.createElement('button');
|
||||
submitButton.type = 'submit';
|
||||
assert_throws('NotFoundError', () => {
|
||||
form.requestSubmit(submitButton);
|
||||
});
|
||||
|
||||
let buttons = form.querySelectorAll('input, button');
|
||||
assert_equals(buttons.length, 2);
|
||||
for (let control of buttons) {
|
||||
assert_throws('NotFoundError', () => { form.requestSubmit(control) },
|
||||
control.outerHTML);
|
||||
}
|
||||
}, 'Passing a submit button not owned by the context object should throw');
|
||||
|
||||
test(() => {
|
||||
document.body.insertAdjacentHTML('afterbegin', `<input type=submit form="form1">
|
||||
<form id="form1" target="_blank">
|
||||
<button type="submit"></button>
|
||||
<button></button>
|
||||
<button type="invalid"></button>
|
||||
<input type="submit">
|
||||
<input type="image">
|
||||
</form>`);
|
||||
let form = document.querySelector('form');
|
||||
let didDispatchSubmit = false;
|
||||
form.addEventListener('submit', event => { event.preventDefault(); didDispatchSubmit = true; });
|
||||
|
||||
assert_equals(form.elements.length, 5);
|
||||
for (let control of form.elements) {
|
||||
didDispatchSubmit = false;
|
||||
form.requestSubmit(control);
|
||||
assert_true(didDispatchSubmit, `${control.outerHTML} should submit the form`);
|
||||
}
|
||||
// <input type=image> is not in form.elements.
|
||||
let control = form.querySelector('[type=image]');
|
||||
didDispatchSubmit = false;
|
||||
form.requestSubmit(control);
|
||||
assert_true(didDispatchSubmit, `${control.outerHTML} should submit the form`);
|
||||
}, 'requestSubmit() should accept button[type=submit], input[type=submit], and input[type=image]');
|
||||
|
||||
test(() => {
|
||||
document.body.insertAdjacentHTML('afterbegin', '<form><input required></form>');
|
||||
let form = document.querySelector('form');
|
||||
let invalidControl = form.querySelector('input:invalid');
|
||||
let didDispatchInvalid = false;
|
||||
invalidControl.addEventListener('invalid', e => { didDispatchInvalid = true; });
|
||||
|
||||
form.requestSubmit();
|
||||
assert_true(didDispatchInvalid);
|
||||
}, 'requestSubmit() should trigger interactive form validation');
|
||||
|
||||
test(() => {
|
||||
document.body.insertAdjacentHTML('afterbegin',
|
||||
'<form><input type=submit></form>');
|
||||
let form = document.querySelector('form');
|
||||
let submitButton = form.elements[0];
|
||||
let submitCounter = 0;
|
||||
form.addEventListener('submit', e => {
|
||||
++submitCounter;
|
||||
form.requestSubmit();
|
||||
e.preventDefault();
|
||||
}, {once: true});
|
||||
form.requestSubmit();
|
||||
assert_equals(submitCounter, 1, 'requestSubmit() + requestSubmit()');
|
||||
|
||||
submitCounter = 0;
|
||||
form.addEventListener('submit', e => {
|
||||
++submitCounter;
|
||||
submitButton.click();
|
||||
e.preventDefault();
|
||||
}, {once: true});
|
||||
form.requestSubmit();
|
||||
assert_equals(submitCounter, 1, 'requestSubmit() + click()');
|
||||
|
||||
submitCounter = 0;
|
||||
form.addEventListener('submit', e => {
|
||||
++submitCounter;
|
||||
form.requestSubmit();
|
||||
e.preventDefault();
|
||||
}, {once: true});
|
||||
submitButton.click();
|
||||
assert_equals(submitCounter, 1, 'click() + requestSubmit()');
|
||||
}, 'requestSubmit() doesn\'t run form submission reentrantly');
|
||||
|
||||
test(() => {
|
||||
document.body.insertAdjacentHTML('afterbegin',
|
||||
'<form><input type=submit><input required></form>');
|
||||
let form = document.querySelector('form');
|
||||
let submitButton = form.elements[0];
|
||||
let invalidControl = form.elements[1];
|
||||
let invalidCounter = 0;
|
||||
invalidControl.addEventListener('invalid', e => {
|
||||
++invalidCounter;
|
||||
if (invalidCounter < 10)
|
||||
form.requestSubmit();
|
||||
}, {once: true});
|
||||
form.requestSubmit();
|
||||
assert_equals(invalidCounter, 1, 'requestSubmit() + requestSubmit()');
|
||||
|
||||
invalidCounter = 0;
|
||||
invalidControl.addEventListener('invalid', e => {
|
||||
++invalidCounter;
|
||||
if (invalidCounter < 10)
|
||||
submitButton.click();
|
||||
}, {once: true});
|
||||
form.requestSubmit();
|
||||
assert_equals(invalidCounter, 1, 'requestSubmit() + click()');
|
||||
|
||||
invalidCounter = 0;
|
||||
invalidControl.addEventListener('invalid', e => {
|
||||
++invalidCounter;
|
||||
if (invalidCounter < 10)
|
||||
form.requestSubmit();
|
||||
}, {once: true});
|
||||
submitButton.click();
|
||||
assert_equals(invalidCounter, 1, 'click() + requestSubmit()');
|
||||
}, 'requestSubmit() doesn\'t run interactive validation reentrantly');
|
||||
|
||||
test(() => {
|
||||
let form = document.createElement('form');
|
||||
let submitCounter = 0;
|
||||
form.addEventListener('submit', e => { ++submitCounter; e.preventDefault(); });
|
||||
form.requestSubmit();
|
||||
assert_equals(submitCounter, 0);
|
||||
}, 'requestSubmit() for a disconnected form should not submit the form');
|
||||
|
||||
async_test(t => {
|
||||
window.addEventListener('load', t.step_func(() => {
|
||||
document.body.insertAdjacentHTML('afterbegin', `
|
||||
<form action="/common/blank.html">
|
||||
<input required>
|
||||
<input type=submit formnovalidate formtarget=iframe name=s value=v>
|
||||
</form>`);
|
||||
let form = document.body.querySelector('form');
|
||||
let iframe = document.body.querySelector('iframe');
|
||||
assert_true(form.matches(':invalid'), 'The form is invalid.');
|
||||
// The form should be submitted though it is invalid.
|
||||
iframe.addEventListener('load', t.step_func_done(() => {
|
||||
assert_not_equals(iframe.contentWindow.location.search.indexOf('s=v'), -1);
|
||||
}));
|
||||
form.requestSubmit(form.querySelector('[type=submit]'));
|
||||
}));
|
||||
}, 'The value of the submitter should be appended, and form* ' +
|
||||
'attributes of the submitter should be handled.');
|
||||
</script>
|
|
@ -0,0 +1 @@
|
|||
["en", "try"]
|
|
@ -0,0 +1 @@
|
|||
false
|
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>JSON modules: invalid Content-Type</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
const content_types = [
|
||||
"application/json+protobuf",
|
||||
"application/json+blah",
|
||||
"text/x-json",
|
||||
"text/json+blah",
|
||||
"application/blahjson",
|
||||
"image/json",
|
||||
];
|
||||
for (const content_type of content_types) {
|
||||
async_test(t => {
|
||||
const script = document.createElement("script");
|
||||
script.onerror = t.step_func_done();
|
||||
script.onload = t.unreached_func("Should not load");
|
||||
script.type = "module";
|
||||
script.src = `module.json?pipe=header(Content-Type,${content_type})`;
|
||||
document.body.appendChild(script);
|
||||
}, content_type);
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>JSON modules</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
const t = async_test();
|
||||
</script>
|
||||
<script type="module" onerror="t.step(() => assert_unreached(event))">
|
||||
import v from "./module.json";
|
||||
t.step(() => {
|
||||
assert_equals(typeof v, "object");
|
||||
assert_array_equals(Object.keys(v), ["test"]);
|
||||
assert_equals(v.test, true);
|
||||
t.done();
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"test": true
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
// META: global=window,worker
|
||||
|
||||
for (const value of [null, true, false, "string"]) {
|
||||
promise_test(async t => {
|
||||
const result = await import(`./${value}.json`);
|
||||
assert_equals(result, value);
|
||||
}, `Non-object: ${value}`);
|
||||
}
|
||||
|
||||
promise_test(async t => {
|
||||
const result = await import("./array.json");
|
||||
assert_array_equals(result, ["en", "try"]);
|
||||
}, "Non-object: array");
|
||||
|
|
@ -0,0 +1 @@
|
|||
null
|
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>JSON modules: parse error</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
setup({
|
||||
allow_uncaught_exception: true,
|
||||
});
|
||||
async_test(t => {
|
||||
window.addEventListener("error", t.step_func_done(e => {
|
||||
assert_true(e instanceof ErrorEvent, "ErrorEvent");
|
||||
assert_equals(e.filename, new URL("parse-error.json", location).href);
|
||||
assert_true(e.error instanceof SyntaxError, "SyntaxError");
|
||||
}));
|
||||
});
|
||||
</script>
|
||||
<script type="module">
|
||||
import v from "./parse-error.json";
|
||||
</script>
|
|
@ -0,0 +1 @@
|
|||
{
|
|
@ -0,0 +1 @@
|
|||
"string"
|
|
@ -0,0 +1 @@
|
|||
true
|
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>JSON modules: UTF-8 decoding</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
function check(t, v) {
|
||||
t.step(() => {
|
||||
assert_equals(typeof v, "object");
|
||||
assert_array_equals(Object.keys(v), ["test"]);
|
||||
assert_equals(v.test, "\u2026");
|
||||
t.done();
|
||||
});
|
||||
}
|
||||
const t1 = async_test("utf-8");
|
||||
const t2 = async_test("shift-jis");
|
||||
const t3 = async_test("windows-1252");
|
||||
const t4 = async_test("utf-7");
|
||||
</script>
|
||||
<script type="module" onerror="t1.step(() => assert_unreached(event))">
|
||||
import v from "../serve-with-content-type.py?fn=json-module/utf8.json&ct=text/json%3Bcharset=utf-8";
|
||||
check(t1, v);
|
||||
</script>
|
||||
<script type="module" onerror="t2.step(() => assert_unreached(event))">
|
||||
import v from "../serve-with-content-type.py?fn=json-module/utf8.json&ct=text/json%3Bcharset=shift-jis";
|
||||
check(t2, v);
|
||||
</script>
|
||||
<script type="module" onerror="t3.step(() => assert_unreached(event))">
|
||||
import v from "../serve-with-content-type.py?fn=json-module/utf8.json&ct=text/json%3Bcharset=windows-1252";
|
||||
check(t3, v);
|
||||
</script>
|
||||
<script type="module" onerror="t4.step(() => assert_unreached(event))">
|
||||
import v from "../serve-with-content-type.py?fn=json-module/utf8.json&ct=text/json%3Bcharset=utf-7";
|
||||
check(t4, v);
|
||||
</script>
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"test": "…"
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>JSON modules: Content-Type</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
function check(t, v) {
|
||||
t.step(() => {
|
||||
assert_equals(typeof v, "object");
|
||||
assert_array_equals(Object.keys(v), ["test"]);
|
||||
assert_equals(v.test, true);
|
||||
t.done();
|
||||
});
|
||||
}
|
||||
const t1 = async_test("text/json");
|
||||
const t2 = async_test("application/json");
|
||||
const t3 = async_test("text/html+json");
|
||||
const t4 = async_test("image/svg+json");
|
||||
</script>
|
||||
<script type="module" onerror="t1.step(() => assert_unreached(event))">
|
||||
import v from "../serve-with-content-type.py?fn=json-module/module.json&ct=text/json";
|
||||
check(t1, v);
|
||||
</script>
|
||||
<script type="module" onerror="t2.step(() => assert_unreached(event))">
|
||||
import v from "../serve-with-content-type.py?fn=json-module/module.json&ct=application/json";
|
||||
check(t2, v);
|
||||
</script>
|
||||
<script type="module" onerror="t3.step(() => assert_unreached(event))">
|
||||
import v from "../serve-with-content-type.py?fn=json-module/module.json&ct=text/html+json";
|
||||
check(t3, v);
|
||||
</script>
|
||||
<script type="module" onerror="t4.step(() => assert_unreached(event))">
|
||||
import v from "../serve-with-content-type.py?fn=json-module/module.json&ct=image/svg+json";
|
||||
check(t4, v);
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue