Update web-platform-tests to revision fd0429f0b45f975b25d85256dac33762134952c5

This commit is contained in:
WPT Sync Bot 2019-04-15 21:58:05 -04:00
parent 0ba7da4431
commit c8202ddbe1
50 changed files with 1210 additions and 191 deletions

View file

@ -0,0 +1,34 @@
// META: title=Blob Array Buffer
// META: script=../support/Blob.js
'use strict';
promise_test(async () => {
const input_arr = new TextEncoder().encode("PASS");
const blob = new Blob([input_arr]);
const array_buffer = await blob.arrayBuffer();
assert_true(array_buffer instanceof ArrayBuffer);
assert_equals_typed_array(new Uint8Array(array_buffer), input_arr);
}, "Blob.arrayBuffer()")
promise_test(async () => {
const input_arr = new TextEncoder().encode("");
const blob = new Blob([input_arr]);
const array_buffer = await blob.arrayBuffer();
assert_true(array_buffer instanceof ArrayBuffer);
assert_equals_typed_array(new Uint8Array(array_buffer), input_arr);
}, "Blob.arrayBuffer() empty Blob data")
promise_test(async () => {
const input_arr = new TextEncoder().encode("\u08B8\u000a");
const blob = new Blob([input_arr]);
const array_buffer = await blob.arrayBuffer();
assert_equals_typed_array(new Uint8Array(array_buffer), input_arr);
}, "Blob.arrayBuffer() non-ascii input")
promise_test(async () => {
const input_arr = [8, 241, 48, 123, 151];
const typed_arr = new Uint8Array(input_arr);
const blob = new Blob([typed_arr]);
const array_buffer = await blob.arrayBuffer();
assert_equals_typed_array(new Uint8Array(array_buffer), typed_arr);
}, "Blob.arrayBuffer() non-unicode input")

View file

@ -0,0 +1,50 @@
// META: title=Blob Stream
// META: script=../support/Blob.js
'use strict';
// Takes in a ReadableStream and reads from it until it is done, returning
// an array that contains the results of each read operation
async function read_all_chunks(stream) {
assert_true(stream instanceof ReadableStream);
assert_true('getReader' in stream);
const reader = stream.getReader();
assert_true('read' in reader);
let read_value = await reader.read();
let out = [];
let i = 0;
while (!read_value.done) {
for (let val of read_value.value) {
out[i++] = val;
}
read_value = await reader.read();
}
return out;
}
promise_test(async () => {
const blob = new Blob(["PASS"]);
const stream = await blob.stream()
const chunks = await read_all_chunks(stream);
for (let [index, value] of chunks.entries()) {
assert_equals(value, "PASS".charCodeAt(index));
}
}, "Blob.stream()")
promise_test(async () => {
const blob = new Blob();
const stream = await blob.stream()
const chunks = await read_all_chunks(stream);
assert_array_equals(chunks, []);
}, "Blob.stream() empty Blob")
promise_test(async () => {
const input_arr = [8, 241, 48, 123, 151];
const typed_arr = new Uint8Array(input_arr);
const blob = new Blob([typed_arr]);
const stream = await blob.stream()
const chunks = await read_all_chunks(stream);
assert_array_equals(chunks, input_arr)
}, "Blob.stream() non-unicode input")

View file

@ -0,0 +1,52 @@
// META: title=Blob Text
// META: script=../support/Blob.js
'use strict';
promise_test(async () => {
const blob = new Blob(["PASS"]);
const text = await blob.text();
assert_equals(text, "PASS");
}, "Blob.text()")
promise_test(async () => {
const blob = new Blob();
const text = await blob.text();
assert_equals(text, "");
}, "Blob.text() empty blob data")
promise_test(async () => {
const blob = new Blob(["P", "A", "SS"]);
const text = await blob.text();
assert_equals(text, "PASS");
}, "Blob.text() multi-element array in constructor")
promise_test(async () => {
const non_unicode = "\u0061\u030A";
const input_arr = new TextEncoder().encode(non_unicode);
const blob = new Blob([input_arr]);
const text = await blob.text();
assert_equals(text, non_unicode);
}, "Blob.text() non-unicode")
promise_test(async () => {
const blob = new Blob(["PASS"], { type: "text/plain;charset=utf-16le" });
const text = await blob.text();
assert_equals(text, "PASS");
}, "Blob.text() different charset param in type option")
promise_test(async () => {
const non_unicode = "\u0061\u030A";
const input_arr = new TextEncoder().encode(non_unicode);
const blob = new Blob([input_arr], { type: "text/plain;charset=utf-16le" });
const text = await blob.text();
assert_equals(text, non_unicode);
}, "Blob.text() different charset param with non-ascii input")
promise_test(async () => {
const input_arr = new Uint8Array([192, 193, 245, 246, 247, 248, 249, 250, 251,
252, 253, 254, 255]);
const blob = new Blob([input_arr]);
const text = await blob.text();
assert_equals(text, "\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd" +
"\ufffd\ufffd\ufffd\ufffd");
}, "Blob.text() invalid utf-8 input")

View file

@ -1,3 +1,5 @@
'use strict'
function test_blob(fn, expectations) {
var expected = expectations.expected,
type = expectations.type,
@ -47,3 +49,22 @@ function test_blob_binary(fn, expectations) {
fr.readAsArrayBuffer(blob);
});
}
// Assert that two TypedArray objects have the same byte values
self.assert_equals_typed_array = (array1, array2) => {
const [view1, view2] = [array1, array2].map((array) => {
assert_true(array.buffer instanceof ArrayBuffer,
'Expect input ArrayBuffers to contain field `buffer`');
return new DataView(array.buffer, array.byteOffset, array.byteLength);
});
assert_equals(view1.byteLength, view2.byteLength,
'Expect both arrays to be of the same byte length');
const byteLength = view1.byteLength;
for (let i = 0; i < byteLength; ++i) {
assert_equals(view1.getUint8(i), view2.getUint8(i),
`Expect byte at buffer position ${i} to be equal`);
}
}

View file

@ -0,0 +1,25 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text Decoration Test: Parsing text-decoration-line with invalid values</title>
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-text-decor-4/#text-decoration-line-property">
<meta name="assert" content="text-decoration-line supports only the grammar 'none | [ underline || overline || line-through || blink ] | spelling-error | grammar-error'.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
<script>
test_invalid_value("text-decoration-line", "auto");
test_invalid_value("text-decoration-line", "null");
test_invalid_value("text-decoration-line", "noone");
test_invalid_value("text-decoration-line", "under-line");
test_invalid_value("text-decoration-line", "over-line");
test_invalid_value("text-decoration-line", "linethrough");
test_invalid_value("text-decoration-line", "none underline");
test_invalid_value("text-decoration-line", "none spelling-error");
test_invalid_value("text-decoration-line", "underline underline");
test_invalid_value("text-decoration-line", "underline none overline");
test_invalid_value("text-decoration-line", "blink line-through blink");
test_invalid_value("text-decoration-line", "spelling-error overline");
test_invalid_value("text-decoration-line", "spelling-error grammar-error");
test_invalid_value("text-decoration-line", "blink underline line-through grammar-error");
</script>

View file

@ -0,0 +1,86 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Text Decoration Test: Parsing text-decoration-line with valid values</title>
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-text-decor-4/#text-decoration-line-property">
<meta name="assert" content="text-decoration-line supports the full grammar 'none | [ underline || overline || line-through || blink ] | spelling-error | grammar-error'.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
<script>
// none
test_valid_value("text-decoration-line", "none");
// underline || overline || line-through || blink
test_valid_value("text-decoration-line", "underline");
test_valid_value("text-decoration-line", "overline");
test_valid_value("text-decoration-line", "line-through");
test_valid_value("text-decoration-line", "blink");
test_valid_value("text-decoration-line", "underline overline");
test_valid_value("text-decoration-line", "overline underline", "underline overline");
test_valid_value("text-decoration-line", "underline line-through");
test_valid_value("text-decoration-line", "line-through underline", "underline line-through");
test_valid_value("text-decoration-line", "underline blink");
test_valid_value("text-decoration-line", "blink underline", "underline blink");
test_valid_value("text-decoration-line", "overline line-through");
test_valid_value("text-decoration-line", "line-through overline", "overline line-through");
test_valid_value("text-decoration-line", "overline blink");
test_valid_value("text-decoration-line", "blink overline", "overline blink");
test_valid_value("text-decoration-line", "line-through blink");
test_valid_value("text-decoration-line", "blink line-through", "line-through blink");
test_valid_value("text-decoration-line", "underline overline line-through");
test_valid_value("text-decoration-line", "underline line-through overline", "underline overline line-through");
test_valid_value("text-decoration-line", "overline underline line-through", "underline overline line-through");
test_valid_value("text-decoration-line", "overline line-through underline", "underline overline line-through");
test_valid_value("text-decoration-line", "line-through underline overline", "underline overline line-through");
test_valid_value("text-decoration-line", "line-through overline underline", "underline overline line-through");
test_valid_value("text-decoration-line", "underline overline blink");
test_valid_value("text-decoration-line", "underline blink overline", "underline overline blink");
test_valid_value("text-decoration-line", "overline underline blink", "underline overline blink");
test_valid_value("text-decoration-line", "overline blink underline", "underline overline blink");
test_valid_value("text-decoration-line", "blink underline overline", "underline overline blink");
test_valid_value("text-decoration-line", "blink overline underline", "underline overline blink");
test_valid_value("text-decoration-line", "underline line-through blink");
test_valid_value("text-decoration-line", "underline blink line-through", "underline line-through blink");
test_valid_value("text-decoration-line", "line-through underline blink", "underline line-through blink");
test_valid_value("text-decoration-line", "line-through blink underline", "underline line-through blink");
test_valid_value("text-decoration-line", "blink underline line-through", "underline line-through blink");
test_valid_value("text-decoration-line", "blink line-through underline", "underline line-through blink");
test_valid_value("text-decoration-line", "overline line-through blink");
test_valid_value("text-decoration-line", "overline blink line-through", "overline line-through blink");
test_valid_value("text-decoration-line", "line-through overline blink", "overline line-through blink");
test_valid_value("text-decoration-line", "line-through blink overline", "overline line-through blink");
test_valid_value("text-decoration-line", "blink overline line-through", "overline line-through blink");
test_valid_value("text-decoration-line", "blink line-through overline", "overline line-through blink");
test_valid_value("text-decoration-line", "underline overline line-through blink");
test_valid_value("text-decoration-line", "underline overline blink line-through", "underline overline line-through blink");
test_valid_value("text-decoration-line", "underline line-through overline blink", "underline overline line-through blink");
test_valid_value("text-decoration-line", "underline line-through blink overline", "underline overline line-through blink");
test_valid_value("text-decoration-line", "underline blink overline line-through", "underline overline line-through blink");
test_valid_value("text-decoration-line", "underline blink line-through overline", "underline overline line-through blink");
test_valid_value("text-decoration-line", "overline underline line-through blink", "underline overline line-through blink");
test_valid_value("text-decoration-line", "overline underline blink line-through", "underline overline line-through blink");
test_valid_value("text-decoration-line", "overline line-through underline blink", "underline overline line-through blink");
test_valid_value("text-decoration-line", "overline line-through blink underline", "underline overline line-through blink");
test_valid_value("text-decoration-line", "overline blink underline line-through", "underline overline line-through blink");
test_valid_value("text-decoration-line", "overline blink line-through underline", "underline overline line-through blink");
test_valid_value("text-decoration-line", "line-through underline overline blink", "underline overline line-through blink");
test_valid_value("text-decoration-line", "line-through underline blink overline", "underline overline line-through blink");
test_valid_value("text-decoration-line", "line-through overline underline blink", "underline overline line-through blink");
test_valid_value("text-decoration-line", "line-through overline blink underline", "underline overline line-through blink");
test_valid_value("text-decoration-line", "line-through blink underline overline", "underline overline line-through blink");
test_valid_value("text-decoration-line", "line-through blink overline underline", "underline overline line-through blink");
test_valid_value("text-decoration-line", "blink underline overline line-through", "underline overline line-through blink");
test_valid_value("text-decoration-line", "blink underline line-through overline", "underline overline line-through blink");
test_valid_value("text-decoration-line", "blink overline underline line-through", "underline overline line-through blink");
test_valid_value("text-decoration-line", "blink overline line-through underline", "underline overline line-through blink");
test_valid_value("text-decoration-line", "blink line-through underline overline", "underline overline line-through blink");
test_valid_value("text-decoration-line", "blink line-through overline underline", "underline overline line-through blink");
// spelling-error
test_valid_value("text-decoration-line", "spelling-error");
// grammar-error
test_valid_value("text-decoration-line", "grammar-error");
</script>

View file

@ -165,8 +165,8 @@ test(function () {
var uncaughtError;
window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; }
instance.cloneNode(false);
assert_equals(uncaughtError.name, 'InvalidStateError');
}, 'HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed'
assert_equals(uncaughtError.name, 'TypeError');
}, 'HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed'
+ ' due to a custom element constructor constructing itself after super() call');
test(function () {
@ -183,8 +183,8 @@ test(function () {
var uncaughtError;
window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; }
instance.cloneNode(false);
assert_equals(uncaughtError.name, 'InvalidStateError');
}, 'HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed'
assert_equals(uncaughtError.name, 'TypeError');
}, 'HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed'
+ ' due to a custom element constructor constructing itself before super() call');
test(function () {
@ -203,8 +203,8 @@ test(function () {
var uncaughtError;
window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; }
instance.cloneNode(false);
assert_equals(uncaughtError.name, 'InvalidStateError');
}, 'Upgrading a custom element must throw InvalidStateError when the custom element\'s constructor returns another element');
assert_equals(uncaughtError.name, 'TypeError');
}, 'Upgrading a custom element must throw TypeError when the custom element\'s constructor returns another element');
test(function () {
var instance = document.createElement('my-custom-element-throw-exception');

View file

@ -15,6 +15,8 @@
<instantiates-itself-before-super></instantiates-itself-before-super>
<my-other-element id="instance"></my-other-element>
<my-other-element id="otherInstance"></my-other-element>
<not-an-element></not-an-element>
<not-an-html-element></not-an-html-element>
<script>
setup({allow_uncaught_exception:true});
@ -48,8 +50,8 @@ test(function () {
var uncaughtError;
window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; }
customElements.define('instantiates-itself-after-super', InstantiatesItselfAfterSuper);
assert_equals(uncaughtError.name, 'InvalidStateError');
}, 'HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed'
assert_equals(uncaughtError.name, 'TypeError');
}, 'HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed'
+ ' due to a custom element constructor constructing itself after super() call');
test(function () {
@ -64,8 +66,8 @@ test(function () {
var uncaughtError;
window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; }
customElements.define('instantiates-itself-before-super', InstantiatesItselfBeforeSuper);
assert_equals(uncaughtError.name, 'InvalidStateError');
}, 'HTMLElement constructor must throw an InvalidStateError when the top of the construction stack is marked AlreadyConstructed'
assert_equals(uncaughtError.name, 'TypeError');
}, 'HTMLElement constructor must throw an TypeError when the top of the construction stack is marked AlreadyConstructed'
+ ' due to a custom element constructor constructing itself before super() call');
test(function () {
@ -85,12 +87,38 @@ test(function () {
var uncaughtError;
window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; }
customElements.define('my-other-element', MyOtherElement);
assert_equals(uncaughtError.name, 'InvalidStateError');
assert_equals(uncaughtError.name, 'TypeError');
assert_true(document.createElement('my-other-element') instanceof MyOtherElement,
'Upgrading of custom elements must happen after the definition was added to the registry.');
}, 'Upgrading a custom element must throw an InvalidStateError when the returned element is not SameValue as the upgraded element');
}, 'Upgrading a custom element must throw an TypeError when the returned element is not SameValue as the upgraded element');
test(() => {
class NotAnElement extends HTMLElement {
constructor() {
return new Text();
}
}
let uncaughtError;
window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; }
customElements.define("not-an-element", NotAnElement);
assert_equals(uncaughtError.name, "TypeError");
}, "Upgrading a custom element whose constructor returns a Text node must throw");
test(() => {
class NotAnHTMLElement extends HTMLElement {
constructor() {
return document.createElementNS("", "test");
}
}
let uncaughtError;
window.onerror = function (message, url, lineNumber, columnNumber, error) { uncaughtError = error; return true; }
customElements.define("not-an-html-element", NotAnHTMLElement);
assert_equals(uncaughtError.name, "TypeError");
}, "Upgrading a custom element whose constructor returns an Element must throw");
</script>
</body>

View file

@ -0,0 +1,53 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/feature-policy/experimental-features/resources/common.js"></script>
<style>
html, body {
height: 100%;
width: 100%;
}
iframe {
width: 400px;
height: 400px;
margin: 10px;
}
.spacer {
width: 100%;
height: 10000px;
}
</style>
<div class="spacer"></div>
<script>
let load_timeout = 600; // ms
let expected_timeout_msg = false;
let cross_origin_url =
"http://{{hosts[alt][www]}}:{{ports[http][0]}}/" +
"feature-policy/experimental-features/resources/lazyload-contents.html";
window.scrollTo(0, 0);
// Verify that when 'loading-frame-default-eager' policy is disabled, the
// loading attribute "auto" leads to lazy loading.
promise_test(async(t) => {
// Add a frame with load="off".
let frame_loading_auto = createIframe(document.body, {
id: "auto",
// Sets the "loading" attribute to "auto".
loading: "auto",
src: `${cross_origin_url}?id=auto`
});
// Sanity-check: The frame is not visible.
assert_greater_than(
frame_loading_auto.getBoundingClientRect().top,
window.innerHeight * 2,
"Unexpected position for <iframe> with ID 'auto'.");
let msg_or_timeout =
await waitForMessageOrTimeout(t, "auto", load_timeout);
assert_false(msg_or_timeout, "Expected the frame not to load.");
}, "When 'loading-frame-default-eager' feature is disabled, a frame with " +
"'loading attribute 'auto' will be lazily loaded.");
</script>

View file

@ -0,0 +1,36 @@
<!DOCTYPE html>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/fetch/sec-metadata/resources/helper.js></script>
<script src=/common/utils.js></script>
<body></body>
<script>
test(t => {
assert_true(document.createElement('link').relList.supports('prefetch'));
}, "Browser supports prefetch.");
function create_test(host, expected) {
async_test(t => {
let nonce = token();
let key = "prefetch" + nonce;
let e = document.createElement('link');
e.rel = "prefetch";
e.href = `https://${host}/fetch/sec-metadata/resources/record-header.py?file=${key}`;
e.setAttribute("crossorigin", "crossorigin");
e.onload = t.step_func(e => {
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(t.step_func(response => response.text()))
.then(t.step_func_done(text => assert_header_equals(text, expected)))
.catch(t.unreached_func("Fetching and verifying the results should succeed."));
});
e.onerror = t.unreached_func();
document.head.appendChild(e);
}, `<link rel='prefetch' href='https://${host}/...'>`);
}
create_test("{{host}}:{{ports[https][0]}}", {"dest":"empty", "site":"same-origin", "user":"", "mode": "cors"});
create_test("{{hosts[][www]}}:{{ports[https][0]}}", {"dest":"empty", "site":"same-site", "user":"", "mode": "cors"});
create_test("{{hosts[alt][www]}}:{{ports[https][0]}}", {"dest":"empty", "site":"cross-site", "user":"", "mode": "cors"});
</script>

View file

@ -0,0 +1,50 @@
<!DOCTYPE html>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/fetch/sec-metadata/resources/helper.js></script>
<script src=/common/utils.js></script>
<body></body>
<script>
test(t => {
assert_true(document.createElement('link').relList.supports('preload'));
}, "Browser supports preload.");
function create_test(host, as, expected) {
async_test(t => {
let nonce = token();
let key = as + nonce;
let e = document.createElement('link');
e.rel = "preload";
e.href = `https://${host}/fetch/sec-metadata/resources/record-header.py?file=${key}`;
e.setAttribute("crossorigin", "crossorigin");
if (as !== undefined) {
e.setAttribute("as", as);
}
e.onload = e.onerror = t.step_func_done(e => {
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(t.step_func(response => response.text()))
.then(t.step_func(text => assert_header_equals(text, expected)))
.then(t.step_func_done(_ => resolve()))
.catch(t.unreached_func());
});
document.head.appendChild(e);
}, `<link rel='preload' as='${as}' href='https://${host}/...'>`);
}
let as_tests = [
[ "fetch", "empty" ],
[ "font", "font" ],
[ "image", "image" ],
[ "script", "script" ],
[ "style", "style" ],
[ "track", "track" ],
];
as_tests.forEach(item => {
create_test("{{host}}:{{ports[https][0]}}", item[0], {"dest":item[1], "site":"same-origin", "user":"", "mode": "cors"});
create_test("{{hosts[][www]}}:{{ports[https][0]}}", item[0], {"dest":item[1], "site":"same-site", "user":"", "mode": "cors"});
create_test("{{hosts[alt][www]}}:{{ports[https][0]}}", item[0], {"dest":item[1], "site":"cross-site", "user":"", "mode": "cors"});
});
</script>

View file

@ -54,6 +54,14 @@ def main(request, response):
if key.startswith("serviceworker"):
response.headers.set("Content-Type", "application/javascript")
## Add a valid image Content-Type ##
if key.startswith("image"):
response.headers.set("Content-Type", "image/png")
file = open(os.path.join(request.doc_root, "media", "1x1-green.png"), "r")
image = file.read()
file.close()
return image
## Return a valid .vtt content for the <track> tag ##
if key.startswith("track"):
return "WEBVTT"

View file

@ -0,0 +1,45 @@
[9, "x"].forEach(function(key) {
test(function() {
var element = document.createElement("div");
var dataset = element.dataset;
var value = "value for " + this.name;
assert_equals(dataset[key], undefined);
element.setAttribute("data-" + key, value);
assert_equals(element.getAttribute("data-" + key), value);
assert_equals(dataset[key], value);
var propdesc = Object.getOwnPropertyDescriptor(dataset, key);
assert_not_equals(propdesc, undefined);
assert_equals(propdesc.value, value);
assert_true(propdesc.writable);
assert_true(propdesc.enumerable);
assert_true(propdesc.configurable);
}, "Getting property descriptor for key " + key);
test(function() {
var element = document.createElement("div");
var dataset = element.dataset;
var proto = "proto getter for " + this.name;
var calledSetter = [];
Object.defineProperty(DOMStringMap.prototype, key, {
"get": function() { return proto; },
"set": this.unreached_func("Should not call [[Set]] on prototype"),
"configurable": true,
});
this.add_cleanup(function() {
delete DOMStringMap.prototype[key];
});
var value = "value for " + this.name;
assert_equals(dataset[key], proto);
assert_equals(element.getAttribute("data-" + key), null);
assert_equals(dataset[key] = value, value);
assert_equals(dataset[key], value);
assert_equals(element.getAttribute("data-" + key), value);
}, "Setting property for key " + key + " with accessor property on prototype");
});

View file

@ -15,6 +15,11 @@ interface Blob {
Blob slice(optional [Clamp] long long start,
optional [Clamp] long long end,
optional DOMString contentType);
// read from the Blob.
[NewObject] ReadableStream stream();
[NewObject] Promise<USVString> text();
[NewObject] Promise<ArrayBuffer> arrayBuffer();
};
enum EndingType { "transparent", "native" };

View file

@ -73,15 +73,15 @@
});
var actions = new test_driver.Actions();
actions.pointerMove(/* x = */ 0, /* y = */ 0, {origin: target}).pointerDown();
actions.pointerMove(/* x = */ 0, /* y = */ 0, {origin: div1}).pointerDown();
pos_x = target.getBoundingClientRect().x + target.offsetWidth / 2;
pos_y = target.getBoundingClientRect().y + target.offsetHeight / 2;
pos_x = div1.offsetWidth / 2;
pos_y = div1.offsetHeight / 2;
for (var i = 0; i < 10; i++) {
// Alternatively move left/right and up/down.
pos_x += ((-1)**i) * i * 10;
pos_y -= ((-1)**i) * i * 10;
actions.pointerMove(pos_x, pos_y);
actions.pointerMove(pos_x, pos_y, {origin: div1});
}
actions.pointerUp().send();
}

View file

@ -0,0 +1,25 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
// Even though UA-generated portalactivate events are different, the
// properties supplied should be used.
const e = new PortalActivateEvent("eventtype", { bubbles: true, cancelable: true });
assert_equals(e.type, "eventtype");
assert_true(e.bubbles);
assert_true(e.cancelable);
assert_equals(null, e.data);
}, "It should be possible to construct a PortalActivateEvent with a dictionary");
test(() => {
const data = {};
const e = new PortalActivateEvent("portalactivate", { data });
assert_equals(data, e.data);
}, "A PortalActivateEvent should expose exactly the data object supplied in the original realm");
test(() => {
const e = new PortalActivateEvent("portalactivate");
assert_throws("InvalidStateError", () => e.adoptPredecessor());
}, "Invoking adoptPredecessor on a synthetic PortalActivateEvent should throw");
</script>

View file

@ -15,7 +15,7 @@ try:
except ImportError:
zstandard = None
from .vcs import Git
from .utils import git
from . import log
@ -40,9 +40,9 @@ def should_download(manifest_path, rebuild_time=timedelta(days=5)):
def merge_pr_tags(repo_root, max_count=50):
git = Git.get_func(repo_root)
gitfunc = git(repo_root)
tags = []
for line in git("log", "--format=%D", "--max-count=%s" % max_count).split("\n"):
for line in gitfunc("log", "--format=%D", "--max-count=%s" % max_count).split("\n"):
for ref in line.split(", "):
if ref.startswith("tag: merge_pr_"):
tags.append(ref[5:])

View file

@ -470,7 +470,7 @@ def load_and_update(tests_root,
rebuild=False,
metadata_path=None,
cache_root=None,
working_copy=False,
working_copy=True,
types=None,
meta_filters=None,
write_manifest=True,

View file

@ -3,7 +3,7 @@ import subprocess
import mock
from .. import vcs
from .. import utils
def test_git_for_path_no_git():
@ -11,4 +11,4 @@ def test_git_for_path_no_git():
with mock.patch(
"subprocess.check_output",
side_effect=subprocess.CalledProcessError(1, "foo")):
assert vcs.Git.for_path(this_dir, "/", this_dir) is None
assert utils.git(this_dir) is None

View file

@ -17,7 +17,7 @@ logger = get_logger()
def update(tests_root,
manifest,
manifest_path=None,
working_copy=False,
working_copy=True,
cache_root=None,
rebuild=False):
logger.warning("Deprecated; use manifest.load_and_update instead")
@ -41,8 +41,7 @@ def update_from_cli(**kwargs):
kwargs["url_base"],
update=True,
rebuild=kwargs["rebuild"],
cache_root=kwargs["cache_root"],
working_copy=kwargs["work"])
cache_root=kwargs["cache_root"])
def abs_path(path):
@ -58,9 +57,6 @@ def create_parser():
parser.add_argument(
"-r", "--rebuild", action="store_true", default=False,
help="Force a full rebuild of the manifest.")
parser.add_argument(
"--work", action="store_true", default=False,
help="Build from the working tree rather than the latest commit")
parser.add_argument(
"--url-base", action="store", default="/",
help="Base url to use as the mount point for tests in this manifest.")

View file

@ -1,5 +1,6 @@
import platform
import os
import platform
import subprocess
from six import BytesIO
@ -32,6 +33,27 @@ def to_os_path(path):
return path.replace("/", os.path.sep)
def git(path):
def gitfunc(cmd, *args):
full_cmd = ["git", cmd] + list(args)
try:
return subprocess.check_output(full_cmd, cwd=path, stderr=subprocess.STDOUT)
except Exception as e:
if platform.uname()[0] == "Windows" and isinstance(e, WindowsError):
full_cmd[0] = "git.bat"
return subprocess.check_output(full_cmd, cwd=path, stderr=subprocess.STDOUT)
else:
raise
try:
# this needs to be a command that fails if we aren't in a git repo
gitfunc("rev-parse", "--show-toplevel")
except (subprocess.CalledProcessError, OSError):
return None
else:
return gitfunc
class ContextManagerBytesIO(BytesIO):
def __enter__(self):
return self

View file

@ -1,13 +1,10 @@
import json
import os
import platform
import stat
import subprocess
from collections import deque
from six import iteritems
from .sourcefile import SourceFile
from .utils import git
MYPY = False
if MYPY:
@ -16,7 +13,7 @@ if MYPY:
def get_tree(tests_root, manifest, manifest_path, cache_root,
working_copy=False, rebuild=False):
working_copy=True, rebuild=False):
tree = None
if cache_root is None:
cache_root = os.path.join(tests_root, ".wptcache")
@ -27,11 +24,8 @@ def get_tree(tests_root, manifest, manifest_path, cache_root,
cache_root = None
if not working_copy:
tree = Git.for_path(tests_root,
manifest.url_base,
manifest_path=manifest_path,
cache_path=cache_root,
rebuild=rebuild)
raise ValueError("working_copy=False unsupported")
if tree is None:
tree = FileSystem(tests_root,
manifest.url_base,
@ -41,39 +35,9 @@ def get_tree(tests_root, manifest, manifest_path, cache_root,
return tree
class Git(object):
def __init__(self, repo_root, url_base, cache_path, manifest_path=None,
rebuild=False):
self.root = repo_root
self.git = Git.get_func(repo_root)
self.url_base = url_base
# rebuild is a noop for now since we don't cache anything
@staticmethod
def get_func(repo_path):
def git(cmd, *args):
full_cmd = ["git", cmd] + list(args)
try:
return subprocess.check_output(full_cmd, cwd=repo_path, stderr=subprocess.STDOUT)
except Exception as e:
if platform.uname()[0] == "Windows" and isinstance(e, WindowsError):
full_cmd[0] = "git.bat"
return subprocess.check_output(full_cmd, cwd=repo_path, stderr=subprocess.STDOUT)
else:
raise
return git
@classmethod
def for_path(cls, path, url_base, cache_path, manifest_path=None, rebuild=False):
git = Git.get_func(path)
try:
# this needs to be a command that fails if we aren't in a git repo
git("rev-parse", "--show-toplevel")
except (subprocess.CalledProcessError, OSError):
return None
else:
return cls(path, url_base, cache_path,
manifest_path=manifest_path, rebuild=rebuild)
class GitHasher(object):
def __init__(self, path):
self.git = git(path)
def _local_changes(self):
"""get a set of files which have changed between HEAD and working copy"""
@ -95,10 +59,6 @@ class Git(object):
return changes
def _show_file(self, path):
path = os.path.relpath(os.path.abspath(path), self.root)
return self.git("show", "HEAD:%s" % path)
def hash_cache(self):
# type: () -> Dict[str, Optional[str]]
"""
@ -114,20 +74,6 @@ class Git(object):
return hash_cache
def __iter__(self):
for rel_path, hash in iteritems(self.hash_cache()):
if hash is None:
contents = self._show_file(rel_path)
else:
contents = None
yield SourceFile(self.root,
rel_path,
self.url_base,
hash,
contents=contents), True
def dump_caches(self):
pass
class FileSystem(object):
@ -145,7 +91,7 @@ class FileSystem(object):
self.path_filter = gitignore.PathFilter(self.root,
extras=[".git/"],
cache=self.ignore_cache)
git = Git.for_path(root, url_base, cache_path)
git = GitHasher(root)
if git is not None:
self.hash_cache = git.hash_cache()
else:

View file

@ -1210,6 +1210,18 @@ window.Audit = (function() {
this._taskRunner._runNextTask();
}
// Runs |subTask| |time| milliseconds later. |setTimeout| is not allowed in
// WPT linter, so a thin wrapper around the harness's |step_timeout| is
// used here.
timeout(subTask, time) {
async_test((test) => {
test.step_timeout(() => {
subTask();
test.done();
}, time);
});
}
isPassed() {
return this._state === TaskState.FINISHED && this._result;
}

View file

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<title>
Test if activation of worklet thread does not resume context rendering.
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/webaudio/resources/audit.js"></script>
</head>
<body>
<script id="layout-test-code">
const audit = Audit.createTaskRunner();
const context = new AudioContext();
const filePath = 'processors/dummy-processor.js';
// Suspends the context right away and then activate worklet. The current
// time must not advance since the context is suspended.
audit.define(
{label: 'load-worklet-and-suspend'},
async (task, should) => {
context.suspend();
const suspendTime = context.currentTime;
await context.audioWorklet.addModule(filePath);
const dummy = new AudioWorkletNode(context, 'dummy');
dummy.connect(context.destination);
task.timeout(() => {
should(context.currentTime, 'context.currentTime')
.beEqualTo(suspendTime);
should(context.state, 'context.state').beEqualTo('suspended');
task.done();
}, 1000);
});
audit.run();
</script>
</body>
</html>

View file

@ -1,7 +1,8 @@
["localStorage", "sessionStorage"].forEach(function(name) {
[9, "x"].forEach(function(key) {
test(function() {
var value = "value";
var expected = "value for " + this.name;
var value = expected;
var storage = window[name];
storage.clear();
@ -9,13 +10,14 @@
assert_equals(storage[key], undefined);
assert_equals(storage.getItem(key), null);
assert_equals(storage[key] = value, value);
assert_equals(storage[key], "value");
assert_equals(storage.getItem(key), "value");
assert_equals(storage[key], expected);
assert_equals(storage.getItem(key), expected);
}, "Setting property for key " + key + " on " + name);
test(function() {
var expected = "value for " + this.name;
var value = {
toString: function() { return "value"; }
toString: function() { return expected; }
};
var storage = window[name];
@ -24,79 +26,77 @@
assert_equals(storage[key], undefined);
assert_equals(storage.getItem(key), null);
assert_equals(storage[key] = value, value);
assert_equals(storage[key], "value");
assert_equals(storage.getItem(key), "value");
assert_equals(storage[key], expected);
assert_equals(storage.getItem(key), expected);
}, "Setting property with toString for key " + key + " on " + name);
test(function() {
Storage.prototype[key] = "proto";
var proto = "proto for " + this.name;
Storage.prototype[key] = proto;
this.add_cleanup(function() { delete Storage.prototype[key]; });
var value = "value";
var value = "value for " + this.name;
var storage = window[name];
storage.clear();
assert_equals(storage[key], "proto");
assert_equals(storage[key], proto);
assert_equals(storage.getItem(key), null);
assert_equals(storage[key] = value, value);
// Hidden because no [OverrideBuiltins].
assert_equals(storage[key], "proto");
assert_equals(storage[key], proto);
assert_equals(Object.getOwnPropertyDescriptor(storage, key), undefined);
assert_equals(storage.getItem(key), "value");
assert_equals(storage.getItem(key), value);
}, "Setting property for key " + key + " on " + name + " with data property on prototype");
test(function() {
Storage.prototype[key] = "proto";
var proto = "proto for " + this.name;
Storage.prototype[key] = proto;
this.add_cleanup(function() { delete Storage.prototype[key]; });
var value = "value";
var value = "value for " + this.name;
var existing = "existing for " + this.name;
var storage = window[name];
storage.clear();
storage.setItem(key, "existing");
storage.setItem(key, existing);
// Hidden because no [OverrideBuiltins].
assert_equals(storage[key], "proto");
assert_equals(storage[key], proto);
assert_equals(Object.getOwnPropertyDescriptor(storage, key), undefined);
assert_equals(storage.getItem(key), "existing");
assert_equals(storage.getItem(key), existing);
assert_equals(storage[key] = value, value);
assert_equals(storage[key], "proto");
assert_equals(storage[key], proto);
assert_equals(Object.getOwnPropertyDescriptor(storage, key), undefined);
assert_equals(storage.getItem(key), "value");
assert_equals(storage.getItem(key), value);
}, "Setting property for key " + key + " on " + name + " with data property on prototype and existing item");
test(function() {
var calledSetter = [];
Object.defineProperty(Storage.prototype, key, {
"get": function() { return "proto getter"; },
"set": function(v) { calledSetter.push(v); },
configurable: true,
});
this.add_cleanup(function() { delete Storage.prototype[key]; });
var value = "value";
var storage = window[name];
storage.clear();
assert_equals(storage[key], "proto getter");
var proto = "proto getter for " + this.name;
Object.defineProperty(Storage.prototype, key, {
"get": function() { return proto; },
"set": this.unreached_func("Should not call [[Set]] on prototype"),
"configurable": true,
});
this.add_cleanup(function() {
delete Storage.prototype[key];
delete storage[key];
assert_false(key in storage);
});
var value = "value for " + this.name;
assert_equals(storage[key], proto);
assert_equals(storage.getItem(key), null);
assert_equals(storage[key] = value, value);
// Property is hidden because no [OverrideBuiltins].
if (typeof key === "number") {
// P is an array index: call through to OrdinarySetWithOwnDescriptor()
assert_array_equals(calledSetter, [value]);
assert_equals(storage[key], "proto getter");
assert_equals(storage.getItem(key), null);
} else {
// P is not an array index: early return in [[Set]] step 2.
// https://github.com/heycam/webidl/issues/630
assert_equals(storage[key], "proto getter");
assert_equals(Object.getOwnPropertyDescriptor(storage, key), undefined);
assert_equals(storage.getItem(key), "value");
}
assert_equals(storage[key], proto);
assert_equals(Object.getOwnPropertyDescriptor(storage, key), undefined);
assert_equals(storage.getItem(key), value);
}, "Setting property for key " + key + " on " + name + " with accessor property on prototype");
});
});

View file

@ -3,40 +3,53 @@
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="resources/webxr_util.js"></script>
<canvas></canvas>
<script>
xr_promise_test(
"Ensure that XRPresentationContexts are properly transfered between session",
(t) => {
return XRTest.simulateDeviceConnection({ supportsImmersive:false })
.then( (controller) => {
Promise.all([
return Promise.all([
navigator.xr.requestSession({ mode: 'inline'}),
navigator.xr.requestSession({ mode: 'inline'})
]).then((sessions) => {
assert_not_equals(sessions[0], null);
assert_not_equals(sessions[1], null);
t.step(() => {
assert_not_equals(sessions[0], null);
assert_not_equals(sessions[1], null);
});
const webglCanvas = document.getElementsByTagName('canvas')[0];
let gl = webglCanvas.getContext('webgl', {xrCompatible: true});
let outputContext = getOutputContext();
sessions[0].updateRenderState({
baseLayer: new XRWebGLLayer(session, gl),
baseLayer: new XRWebGLLayer(sessions[0], gl),
outputContext: outputContext
});
sessions[0].requestAnimationFrame((time, xrFrame) => {
sessions[1].updateRenderState({
baseLayer: new XRWebGLLayer(session, gl),
outputContext: outputContext
});
return new Promise((resolve, reject) => {
sessions[0].requestAnimationFrame((time, xrFrame) => {
sessions[1].updateRenderState({
baseLayer: new XRWebGLLayer(sessions[1], gl),
outputContext: outputContext
});
// outputContext reassignment should not happen until the next frame is processed.
assert_equals(sessions[0].renderState.outputContext, outputContext);
assert_equals(sessions[1].renderState.outputContext, null);
t.step(() => {
// outputContext reassignment should not happen until the next frame is processed.
assert_equals(sessions[0].renderState.outputContext, outputContext);
assert_equals(sessions[1].renderState.outputContext, null);
});
sessions[1].requestAnimationFrame((time, xrFrame) => {
// Ensure the outputContext was properly reassigned from one context to the other.
assert_equals(sessions[0].renderState.outputContext, null);
assert_equals(sessions[1].renderState.outputContext, outputContext);
sessions[1].requestAnimationFrame((time, xrFrame) => {
t.step(() => {
// Ensure the outputContext was properly reassigned from one context to the other.
assert_equals(sessions[0].renderState.outputContext, null);
assert_equals(sessions[1].renderState.outputContext, outputContext);
});
resolve();
});
});
});
});