test: update WPT resources, common, streams, FileAPI, broadcastchannel

PR-URL: https://github.com/nodejs/node/pull/46912
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
Filip Skokan authored and Michaël Zasso committed 2023-03-14 07:54:08 +01:00
1 parent adff278c47
commit c8d528e979
108 files changed
+2079 -5279

No files matched your search

+11 -15
View File
@@ -453,14 +453,13 @@ class WPTRunner {
this.scriptsModifier = modifier;
}
fullInitScript(hasSubsetScript, locationSearchString) {
fullInitScript(url, metaTitle) {
let { initScript } = this;
if (hasSubsetScript || locationSearchString) {
initScript = `${initScript}\n\n//===\nglobalThis.location ||= {};`;
}
if (locationSearchString) {
initScript = `${initScript}\n\n//===\nglobalThis.location.search = "${locationSearchString}";`;
initScript = `${initScript}\n\n//===\nglobalThis.location = new URL("${url.href}");`;
if (metaTitle) {
initScript = `${initScript}\n\n//===\nglobalThis.META_TITLE = "${metaTitle}";`;
}
if (this.globalThisInitScripts.length === null) {
@@ -553,13 +552,13 @@ class WPTRunner {
const relativePath = spec.getRelativePath();
const harnessPath = fixtures.path('wpt', 'resources', 'testharness.js');
const scriptsToRun = [];
let hasSubsetScript = false;
let needsGc = false;
// Scripts specified with the `// META: script=` header
if (meta.script) {
for (const script of meta.script) {
if (script === '/common/subset-tests.js' || script === '/common/subset-tests-by-key.js') {
hasSubsetScript = true;
if (script === '/common/gc.js') {
needsGc = true;
}
const obj = {
filename: this.resource.toRealFilePath(relativePath, script),
@@ -592,12 +591,13 @@ class WPTRunner {
testRelativePath: relativePath,
wptRunner: __filename,
wptPath: this.path,
initScript: this.fullInitScript(hasSubsetScript, variant),
initScript: this.fullInitScript(new URL(`/${relativePath.replace(/\.js$/, '.html')}${variant}`, 'http://wpt'), meta.title),
harness: {
code: fs.readFileSync(harnessPath, 'utf8'),
filename: harnessPath,
},
scriptsToRun,
needsGc,
},
});
this.workers.set(testFileName, worker);
@@ -749,11 +749,7 @@ class WPTRunner {
*/
resultCallback(filename, test, reportResult) {
const status = this.getTestStatus(test.status);
const title = this.getTestTitle(filename);
if (/^Untitled( \d+)?$/.test(test.name)) {
test.name = `${title}${test.name.slice(8)}`;
}
console.log(`---- ${title} ----`);
console.log(`---- ${test.name} ----`);
if (status !== kPass) {
this.fail(filename, test, status, reportResult);
} else {
+12 -5
View File
@@ -1,22 +1,29 @@
'use strict';
const { runInThisContext } = require('vm');
const { runInNewContext, runInThisContext } = require('vm');
const { setFlagsFromString } = require('v8');
const { parentPort, workerData } = require('worker_threads');
const { ResourceLoader } = require(workerData.wptRunner);
const resource = new ResourceLoader(workerData.wptPath);
global.self = global;
global.GLOBAL = {
if (workerData.needsGc) {
// See https://github.com/nodejs/node/issues/16595#issuecomment-340288680
setFlagsFromString('--expose-gc');
globalThis.gc = runInNewContext('gc');
}
globalThis.self = global;
globalThis.GLOBAL = {
isWindow() { return false; },
isShadowRealm() { return false; },
};
global.require = require;
globalThis.require = require;
// This is a mock, because at the moment fetch is not implemented
// in Node.js, but some tests and harness depend on this to pull
// resources.
global.fetch = function fetch(file) {
globalThis.fetch = function fetch(file) {
return resource.read(workerData.testRelativePath, file, true);
};
@@ -0,0 +1,59 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Blob methods from detached frame work as expected</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe id="emptyDocumentIframe" src="../support/empty-document.html"></iframe>
<script>
const BlobPrototypeFromDetachedFramePromise = new Promise(resolve => {
emptyDocumentIframe.onload = () => {
const BlobPrototype = emptyDocumentIframe.contentWindow.Blob.prototype;
emptyDocumentIframe.remove();
resolve(BlobPrototype);
};
});
const charCodeArrayToString = charCodeArray => Array.from(charCodeArray, c => String.fromCharCode(c)).join("");
const charCodeBufferToString = charCodeBuffer => charCodeArrayToString(new Uint8Array(charCodeBuffer));
promise_test(async () => {
const { slice } = await BlobPrototypeFromDetachedFramePromise;
const blob = new Blob(["foobar"]);
const slicedBlob = slice.call(blob, 1, 3);
assert_true(slicedBlob instanceof Blob);
assert_equals(await slicedBlob.text(), "oo");
assert_equals(charCodeBufferToString(await slicedBlob.arrayBuffer()), "oo");
const reader = slicedBlob.stream().getReader();
const { value } = await reader.read();
assert_equals(charCodeArrayToString(value), "oo");
}, "slice()");
promise_test(async () => {
const { text } = await BlobPrototypeFromDetachedFramePromise;
const blob = new Blob(["foo"]);
assert_equals(await text.call(blob), "foo");
}, "text()");
promise_test(async () => {
const { arrayBuffer } = await BlobPrototypeFromDetachedFramePromise;
const blob = new Blob(["bar"]);
const charCodeBuffer = await arrayBuffer.call(blob);
assert_equals(charCodeBufferToString(charCodeBuffer), "bar");
}, "arrayBuffer()");
promise_test(async () => {
const { stream } = await BlobPrototypeFromDetachedFramePromise;
const blob = new Blob(["baz"]);
const reader = stream.call(blob).getReader();
const { value } = await reader.read();
assert_equals(charCodeArrayToString(value), "baz");
}, "stream()");
</script>
@@ -0,0 +1,276 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="/common/utils.js"></script>
<script src="/common/dispatcher/dispatcher.js"></script>
<!-- Pull in executor_path needed by newPopup / newIframe -->
<script src="/html/cross-origin-embedder-policy/credentialless/resources/common.js"></script>
<!-- Pull in importScript / newPopup / newIframe -->
<script src="/html/anonymous-iframe/resources/common.js"></script>
<body>
<script>
const did_revoke_response = "URL.revokeObjectURL did revoke";
const did_not_revoke_response = "URL.revokeObjectURL did not revoke";
const can_blob_url_be_revoked_js = (blob_url, response_queue_name) => `
async function test() {
if (!('revokeObjectURL' in URL)) {
return send("${response_queue_name}", "URL.revokeObjectURL is not exposed");
}
try {
var blob = await fetch("${blob_url}").then(response => response.blob());
await blob.text();
} catch {
return send("${response_queue_name}", "Blob URL invalid");
}
try {
URL.revokeObjectURL("${blob_url}");
} catch(e) {
return send("${response_queue_name}", e.toString());
}
try {
const blob = await fetch("${blob_url}").then(response => response.blob());
} catch(e) {
return send("${response_queue_name}", "${did_revoke_response}");
}
return send("${response_queue_name}", "${did_not_revoke_response}");
}
await test();
`;
const add_iframe_js = (iframe_origin, response_queue_uuid) => `
const importScript = ${importScript};
await importScript("/html/cross-origin-embedder-policy/credentialless" +
"/resources/common.js");
await importScript("/html/anonymous-iframe/resources/common.js");
await importScript("/common/utils.js");
await send("${response_queue_uuid}", newIframe("${iframe_origin}"));
`;
const same_site_origin = get_host_info().HTTPS_ORIGIN;
const cross_site_origin = get_host_info().HTTPS_NOTSAMESITE_ORIGIN;
async function create_test_iframes(t, response_queue_uuid) {
// Create a same-origin iframe in a cross-site popup.
const not_same_site_popup_uuid = newPopup(t, cross_site_origin);
await send(not_same_site_popup_uuid,
add_iframe_js(same_site_origin, response_queue_uuid));
const iframe_1_uuid = await receive(response_queue_uuid);
// Create a same-origin iframe in a same-site popup.
const same_origin_popup_uuid = newPopup(t, same_site_origin);
await send(same_origin_popup_uuid,
add_iframe_js(same_site_origin, response_queue_uuid));
const iframe_2_uuid = await receive(response_queue_uuid);
return [iframe_1_uuid, iframe_2_uuid];
}
promise_test(t => {
return new Promise(async (resolve, reject) => {
try {
const response_queue_uuid = token();
const [iframe_1_uuid, iframe_2_uuid] =
await create_test_iframes(t, response_queue_uuid);
const blob = new Blob(["blob data"], {type : "text/plain"});
const blob_url = window.URL.createObjectURL(blob);
t.add_cleanup(() => window.URL.revokeObjectURL(blob_url));
await send(iframe_1_uuid,
can_blob_url_be_revoked_js(blob_url, response_queue_uuid));
var response = await receive(response_queue_uuid);
if (response !== did_not_revoke_response) {
reject(`Blob URL was revoked in not-same-top-level-site iframe: ${response}`);
}
await send(iframe_2_uuid,
can_blob_url_be_revoked_js(blob_url, response_queue_uuid));
response = await receive(response_queue_uuid);
if (response !== did_revoke_response) {
reject(`Blob URL wasn't revoked in same-top-level-site iframe: ${response}`);
}
resolve();
} catch (e) {
reject(e);
}
});
}, "Blob URL shouldn't be revocable from a cross-partition iframe");
const newWorker = (origin) => {
const worker_token = token();
const worker_url = origin + executor_worker_path + `&uuid=${worker_token}`;
const worker = new Worker(worker_url);
return worker_token;
}
promise_test(t => {
return new Promise(async (resolve, reject) => {
try {
const response_queue_uuid = token();
const create_worker_js = (origin) => `
const importScript = ${importScript};
await importScript("/html/cross-origin-embedder-policy/credentialless" +
"/resources/common.js");
await importScript("/html/anonymous-iframe/resources/common.js");
await importScript("/common/utils.js");
const newWorker = ${newWorker};
await send("${response_queue_uuid}", newWorker("${origin}"));
`;
const [iframe_1_uuid, iframe_2_uuid] =
await create_test_iframes(t, response_queue_uuid);
// Create a dedicated worker in the cross-top-level-site iframe.
await send(iframe_1_uuid, create_worker_js(same_site_origin));
const worker_1_uuid = await receive(response_queue_uuid);
// Create a dedicated worker in the same-top-level-site iframe.
await send(iframe_2_uuid, create_worker_js(same_site_origin));
const worker_2_uuid = await receive(response_queue_uuid);
const blob = new Blob(["blob data"], {type : "text/plain"});
const blob_url = window.URL.createObjectURL(blob);
t.add_cleanup(() => window.URL.revokeObjectURL(blob_url));
await send(worker_1_uuid,
can_blob_url_be_revoked_js(blob_url, response_queue_uuid));
var response = await receive(response_queue_uuid);
if (response !== did_not_revoke_response) {
reject(`Blob URL was revoked in not-same-top-level-site dedicated worker: ${response}`);
}
await send(worker_2_uuid,
can_blob_url_be_revoked_js(blob_url, response_queue_uuid));
response = await receive(response_queue_uuid);
if (response !== did_revoke_response) {
reject(`Blob URL wasn't revoked in same-top-level-site dedicated worker: ${response}`);
}
resolve();
} catch (e) {
reject(e);
}
});
}, "Blob URL shouldn't be revocable from a cross-partition dedicated worker");
const newSharedWorker = (origin) => {
const worker_token = token();
const worker_url = origin + executor_worker_path + `&uuid=${worker_token}`;
const worker = new SharedWorker(worker_url, worker_token);
return worker_token;
}
promise_test(t => {
return new Promise(async (resolve, reject) => {
try {
const response_queue_uuid = token();
const create_worker_js = (origin) => `
const importScript = ${importScript};
await importScript("/html/cross-origin-embedder-policy/credentialless" +
"/resources/common.js");
await importScript("/html/anonymous-iframe/resources/common.js");
await importScript("/common/utils.js");
const newSharedWorker = ${newSharedWorker};
await send("${response_queue_uuid}", newSharedWorker("${origin}"));
`;
const [iframe_1_uuid, iframe_2_uuid] =
await create_test_iframes(t, response_queue_uuid);
// Create a shared worker in the cross-top-level-site iframe.
await send(iframe_1_uuid, create_worker_js(same_site_origin));
const worker_1_uuid = await receive(response_queue_uuid);
// Create a shared worker in the same-top-level-site iframe.
await send(iframe_2_uuid, create_worker_js(same_site_origin));
const worker_2_uuid = await receive(response_queue_uuid);
const blob = new Blob(["blob data"], {type : "text/plain"});
const blob_url = window.URL.createObjectURL(blob);
t.add_cleanup(() => window.URL.revokeObjectURL(blob_url));
await send(worker_1_uuid,
can_blob_url_be_revoked_js(blob_url, response_queue_uuid));
var response = await receive(response_queue_uuid);
if (response !== did_not_revoke_response) {
reject(`Blob URL was revoked in not-same-top-level-site shared worker: ${response}`);
}
await send(worker_2_uuid,
can_blob_url_be_revoked_js(blob_url, response_queue_uuid));
response = await receive(response_queue_uuid);
if (response !== did_revoke_response) {
reject(`Blob URL wasn't revoked in same-top-level-site shared worker: ${response}`);
}
resolve();
} catch (e) {
reject(e);
}
});
}, "Blob URL shouldn't be revocable from a cross-partition shared worker");
const newServiceWorker = async (origin) => {
const worker_token = token();
const worker_url = origin + executor_service_worker_path +
`&uuid=${worker_token}`;
const worker_url_path = executor_service_worker_path.substring(0,
executor_service_worker_path.lastIndexOf('/'));
const scope = worker_url_path + "/not-used/";
const reg = await navigator.serviceWorker.register(worker_url,
{'scope': scope});
return worker_token;
}
promise_test(t => {
return new Promise(async (resolve, reject) => {
try {
const response_queue_uuid = token();
const create_worker_js = (origin) => `
const importScript = ${importScript};
await importScript("/html/cross-origin-embedder-policy/credentialless" +
"/resources/common.js");
await importScript("/html/anonymous-iframe/resources/common.js");
await importScript("/common/utils.js");
const newServiceWorker = ${newServiceWorker};
await send("${response_queue_uuid}", await newServiceWorker("${origin}"));
`;
const [iframe_1_uuid, iframe_2_uuid] =
await create_test_iframes(t, response_queue_uuid);
// Create a service worker in either iframe.
await send(iframe_1_uuid, create_worker_js(same_site_origin));
var worker_1_uuid = await receive(response_queue_uuid);
t.add_cleanup(() =>
send(worker_1_uuid, "self.registration.unregister();"));
const blob = new Blob(["blob data"], {type : "text/plain"});
const blob_url = window.URL.createObjectURL(blob);
t.add_cleanup(() => window.URL.revokeObjectURL(blob_url));
await send(worker_1_uuid,
can_blob_url_be_revoked_js(blob_url, response_queue_uuid));
const response = await receive(response_queue_uuid);
if (response !== "URL.revokeObjectURL is not exposed") {
reject(`URL.revokeObjectURL is exposed in a Service Worker context: ${response}`);
}
resolve();
} catch (e) {
reject(e);
}
});
}, "Blob URL shouldn't be revocable from a service worker");
</script>
</body>
+10 -1
View File
@@ -311,7 +311,16 @@ test_blob(function() {
desc: "Passing a Float64Array as element of the blobParts array should work."
});
test_blob(function() {
return new Blob([
new BigInt64Array([BigInt("0x5353415053534150")]),
new BigUint64Array([BigInt("0x5353415053534150")])
]);
}, {
expected: "PASSPASSPASSPASS",
type: "",
desc: "Passing BigInt typed arrays as elements of the blobParts array should work."
});
var t_ports = async_test("Passing a FrozenArray as the blobParts array should work (FrozenArray<MessagePort>).");
t_ports.step(function() {
-501
View File
@@ -1,501 +0,0 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Blob constructor</title>
<link rel=help href="http://dev.w3.org/2006/webapi/FileAPI/#constructorBlob">
<link rel=help href="https://heycam.github.io/webidl/#es-union">
<link rel=help href="https://heycam.github.io/webidl/#es-dictionary">
<link rel=help href="https://heycam.github.io/webidl/#es-sequence">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/Blob.js"></script>
<div id="log"></div>
<script>
test(function() {
assert_true("Blob" in window, "window should have a Blob property.");
assert_equals(Blob.length, 0, "Blob.length should be 0.");
assert_true(Blob instanceof Function, "Blob should be a function.");
}, "Blob interface object");
// Step 1.
test(function() {
var blob = new Blob();
assert_true(blob instanceof Blob);
assert_equals(String(blob), '[object Blob]');
assert_equals(blob.size, 0);
assert_equals(blob.type, "");
}, "Blob constructor with no arguments");
test(function() {
assert_throws_js(TypeError, function() { var blob = Blob(); });
}, "Blob constructor with no arguments, without 'new'");
test(function() {
var blob = new Blob;
assert_true(blob instanceof Blob);
assert_equals(blob.size, 0);
assert_equals(blob.type, "");
}, "Blob constructor without brackets");
test(function() {
var blob = new Blob(undefined);
assert_true(blob instanceof Blob);
assert_equals(String(blob), '[object Blob]');
assert_equals(blob.size, 0);
assert_equals(blob.type, "");
}, "Blob constructor with undefined as first argument");
// blobParts argument (WebIDL).
test(function() {
var args = [
null,
true,
false,
0,
1,
1.5,
"FAIL",
new Date(),
new RegExp(),
{},
{ 0: "FAIL", length: 1 },
document.createElement("div"),
window,
];
args.forEach(function(arg) {
assert_throws_js(TypeError, function() {
new Blob(arg);
}, "Should throw for argument " + format_value(arg) + ".");
});
}, "Passing non-objects, Dates and RegExps for blobParts should throw a TypeError.");
test_blob(function() {
return new Blob({
[Symbol.iterator]: Array.prototype[Symbol.iterator],
});
}, {
expected: "",
type: "",
desc: "A plain object with @@iterator should be treated as a sequence for the blobParts argument."
});
test(t => {
const blob = new Blob({
[Symbol.iterator]() {
var i = 0;
return {next: () => [
{done:false, value:'ab'},
{done:false, value:'cde'},
{done:true}
][i++]
};
}
});
assert_equals(blob.size, 5, 'Custom @@iterator should be treated as a sequence');
}, "A plain object with custom @@iterator should be treated as a sequence for the blobParts argument.");
test_blob(function() {
return new Blob({
[Symbol.iterator]: Array.prototype[Symbol.iterator],
0: "PASS",
length: 1
});
}, {
expected: "PASS",
type: "",
desc: "A plain object with @@iterator and a length property should be treated as a sequence for the blobParts argument."
});
test_blob(function() {
return new Blob(new String("xyz"));
}, {
expected: "xyz",
type: "",
desc: "A String object should be treated as a sequence for the blobParts argument."
});
test_blob(function() {
return new Blob(new Uint8Array([1, 2, 3]));
}, {
expected: "123",
type: "",
desc: "A Uint8Array object should be treated as a sequence for the blobParts argument."
});
var test_error = {
name: "test",
message: "test error",
};
test(function() {
var obj = {
[Symbol.iterator]: Array.prototype[Symbol.iterator],
get length() { throw test_error; }
};
assert_throws_exactly(test_error, function() {
new Blob(obj);
});
}, "The length getter should be invoked and any exceptions should be propagated.");
test(function() {
var element = document.createElement("div");
element.appendChild(document.createElement("div"));
element.appendChild(document.createElement("p"));
var list = element.children;
Object.defineProperty(list, "length", {
get: function() { throw test_error; }
});
assert_throws_exactly(test_error, function() {
new Blob(list);
});
}, "A platform object that supports indexed properties should be treated as a sequence for the blobParts argument (overwritten 'length'.)");
test(function() {
assert_throws_exactly(test_error, function() {
var obj = {
[Symbol.iterator]: Array.prototype[Symbol.iterator],
length: {
valueOf: null,
toString: function() { throw test_error; }
}
};
new Blob(obj);
});
assert_throws_exactly(test_error, function() {
var obj = {
[Symbol.iterator]: Array.prototype[Symbol.iterator],
length: { valueOf: function() { throw test_error; } }
};
new Blob(obj);
});
}, "ToUint32 should be applied to the length and any exceptions should be propagated.");
test(function() {
var received = [];
var obj = {
get [Symbol.iterator]() {
received.push("Symbol.iterator");
return Array.prototype[Symbol.iterator];
},
get length() {
received.push("length getter");
return {
valueOf: function() {
received.push("length valueOf");
return 3;
}
};
},
get 0() {
received.push("0 getter");
return {
toString: function() {
received.push("0 toString");
return "a";
}
};
},
get 1() {
received.push("1 getter");
throw test_error;
},
get 2() {
received.push("2 getter");
assert_unreached("Should not call the getter for 2 if the getter for 1 threw.");
}
};
assert_throws_exactly(test_error, function() {
new Blob(obj);
});
assert_array_equals(received, [
"Symbol.iterator",
"length getter",
"length valueOf",
"0 getter",
"0 toString",
"length getter",
"length valueOf",
"1 getter",
]);
}, "Getters and value conversions should happen in order until an exception is thrown.");
// XXX should add tests edge cases of ToLength(length)
test(function() {
assert_throws_exactly(test_error, function() {
new Blob([{ toString: function() { throw test_error; } }]);
}, "Throwing toString");
assert_throws_exactly(test_error, function() {
new Blob([{ toString: undefined, valueOf: function() { throw test_error; } }]);
}, "Throwing valueOf");
assert_throws_exactly(test_error, function() {
new Blob([{
toString: function() { throw test_error; },
valueOf: function() { assert_unreached("Should not call valueOf if toString is present."); }
}]);
}, "Throwing toString and valueOf");
assert_throws_js(TypeError, function() {
new Blob([{toString: null, valueOf: null}]);
}, "Null toString and valueOf");
}, "ToString should be called on elements of the blobParts array and any exceptions should be propagated.");
test_blob(function() {
var arr = [
{ toString: function() { arr.pop(); return "PASS"; } },
{ toString: function() { assert_unreached("Should have removed the second element of the array rather than called toString() on it."); } }
];
return new Blob(arr);
}, {
expected: "PASS",
type: "",
desc: "Changes to the blobParts array should be reflected in the returned Blob (pop)."
});
test_blob(function() {
var arr = [
{
toString: function() {
if (arr.length === 3) {
return "A";
}
arr.unshift({
toString: function() {
assert_unreached("Should only access index 0 once.");
}
});
return "P";
}
},
{
toString: function() {
return "SS";
}
}
];
return new Blob(arr);
}, {
expected: "PASS",
type: "",
desc: "Changes to the blobParts array should be reflected in the returned Blob (unshift)."
});
test_blob(function() {
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=17652
return new Blob([
null,
undefined,
true,
false,
0,
1,
new String("stringobject"),
[],
['x', 'y'],
{},
{ 0: "FAIL", length: 1 },
{ toString: function() { return "stringA"; } },
{ toString: undefined, valueOf: function() { return "stringB"; } },
{ valueOf: function() { assert_unreached("Should not call valueOf if toString is present on the prototype."); } }
]);
}, {
expected: "nullundefinedtruefalse01stringobjectx,y[object Object][object Object]stringAstringB[object Object]",
type: "",
desc: "ToString should be called on elements of the blobParts array."
});
test_blob(function() {
return new Blob([
new ArrayBuffer(8)
]);
}, {
expected: "\0\0\0\0\0\0\0\0",
type: "",
desc: "ArrayBuffer elements of the blobParts array should be supported."
});
test_blob(function() {
return new Blob([
new Uint8Array([0x50, 0x41, 0x53, 0x53]),
new Int8Array([0x50, 0x41, 0x53, 0x53]),
new Uint16Array([0x4150, 0x5353]),
new Int16Array([0x4150, 0x5353]),
new Uint32Array([0x53534150]),
new Int32Array([0x53534150]),
new Float32Array([0xD341500000])
]);
}, {
expected: "PASSPASSPASSPASSPASSPASSPASS",
type: "",
desc: "Passing typed arrays as elements of the blobParts array should work."
});
test_blob(function() {
return new Blob([
// 0x535 3415053534150
// 0x535 = 0b010100110101 -> Sign = +, Exponent = 1333 - 1023 = 310
// 0x13415053534150 * 2**(-52)
// ==> 0x13415053534150 * 2**258 = 2510297372767036725005267563121821874921913208671273727396467555337665343087229079989707079680
new Float64Array([2510297372767036725005267563121821874921913208671273727396467555337665343087229079989707079680])
]);
}, {
expected: "PASSPASS",
type: "",
desc: "Passing a Float64Array as element of the blobParts array should work."
});
test_blob(function() {
var select = document.createElement("select");
select.appendChild(document.createElement("option"));
return new Blob(select);
}, {
expected: "[object HTMLOptionElement]",
type: "",
desc: "Passing an platform object that supports indexed properties as the blobParts array should work (select)."
});
test_blob(function() {
var elm = document.createElement("div");
elm.setAttribute("foo", "bar");
return new Blob(elm.attributes);
}, {
expected: "[object Attr]",
type: "",
desc: "Passing an platform object that supports indexed properties as the blobParts array should work (attributes)."
});
var t_ports = async_test("Passing a FrozenArray as the blobParts array should work (FrozenArray<MessagePort>).");
t_ports.step(function() {
var channel = new MessageChannel();
channel.port2.onmessage = this.step_func(function(e) {
var b_ports = new Blob(e.ports);
assert_equals(b_ports.size, "[object MessagePort]".length);
this.done();
});
var channel2 = new MessageChannel();
channel.port1.postMessage('', [channel2.port1]);
});
test_blob(function() {
var blob = new Blob(['foo']);
return new Blob([blob, blob]);
}, {
expected: "foofoo",
type: "",
desc: "Array with two blobs"
});
test_blob_binary(function() {
var view = new Uint8Array([0, 255, 0]);
return new Blob([view.buffer, view.buffer]);
}, {
expected: [0, 255, 0, 0, 255, 0],
type: "",
desc: "Array with two buffers"
});
test_blob_binary(function() {
var view = new Uint8Array([0, 255, 0, 4]);
var blob = new Blob([view, view]);
assert_equals(blob.size, 8);
var view1 = new Uint16Array(view.buffer, 2);
return new Blob([view1, view.buffer, view1]);
}, {
expected: [0, 4, 0, 255, 0, 4, 0, 4],
type: "",
desc: "Array with two bufferviews"
});
test_blob(function() {
var view = new Uint8Array([0]);
var blob = new Blob(["fo"]);
return new Blob([view.buffer, blob, "foo"]);
}, {
expected: "\0fofoo",
type: "",
desc: "Array with mixed types"
});
test(function() {
const accessed = [];
const stringified = [];
new Blob([], {
get type() { accessed.push('type'); },
get endings() { accessed.push('endings'); }
});
new Blob([], {
type: { toString: () => { stringified.push('type'); return ''; } },
endings: { toString: () => { stringified.push('endings'); return 'transparent'; } }
});
assert_array_equals(accessed, ['endings', 'type']);
assert_array_equals(stringified, ['endings', 'type']);
}, "options properties should be accessed in lexicographic order.");
test(function() {
assert_throws_exactly(test_error, function() {
new Blob(
[{ toString: function() { throw test_error } }],
{
get type() { assert_unreached("type getter should not be called."); }
}
);
});
}, "Arguments should be evaluated from left to right.");
[
null,
undefined,
{},
{ unrecognized: true },
/regex/,
function() {}
].forEach(function(arg, idx) {
test_blob(function() {
return new Blob([], arg);
}, {
expected: "",
type: "",
desc: "Passing " + format_value(arg) + " (index " + idx + ") for options should use the defaults."
});
test_blob(function() {
return new Blob(["\na\r\nb\n\rc\r"], arg);
}, {
expected: "\na\r\nb\n\rc\r",
type: "",
desc: "Passing " + format_value(arg) + " (index " + idx + ") for options should use the defaults (with newlines)."
});
});
[
123,
123.4,
true,
'abc'
].forEach(arg => {
test(t => {
assert_throws_js(TypeError, () => new Blob([], arg),
'Blob constructor should throw with invalid property bag');
}, `Passing ${JSON.stringify(arg)} for options should throw`);
});
var type_tests = [
// blobParts, type, expected type
[[], '', ''],
[[], 'a', 'a'],
[[], 'A', 'a'],
[[], 'text/html', 'text/html'],
[[], 'TEXT/HTML', 'text/html'],
[[], 'text/plain;charset=utf-8', 'text/plain;charset=utf-8'],
[[], '\u00E5', ''],
[[], '\uD801\uDC7E', ''], // U+1047E
[[], ' image/gif ', ' image/gif '],
[[], '\timage/gif\t', ''],
[[], 'image/gif;\u007f', ''],
[[], '\u0130mage/gif', ''], // uppercase i with dot
[[], '\u0131mage/gif', ''], // lowercase dotless i
[[], 'image/gif\u0000', ''],
// check that type isn't changed based on sniffing
[[0x3C, 0x48, 0x54, 0x4D, 0x4C, 0x3E], 'unknown/unknown', 'unknown/unknown'], // "<HTML>"
[[0x00, 0xFF], 'text/plain', 'text/plain'],
[[0x47, 0x49, 0x46, 0x38, 0x39, 0x61], 'image/png', 'image/png'], // "GIF89a"
];
type_tests.forEach(function(t) {
test(function() {
var arr = new Uint8Array([t[0]]).buffer;
var b = new Blob([arr], {type:t[1]});
assert_equals(b.type, t[2]);
}, "Blob with type " + format_value(t[1]));
});
</script>
+5 -10
View File
@@ -1,14 +1,9 @@
importScripts("/resources/testharness.js");
async_test(function() {
var data = "TEST";
var blob = new Blob([data], {type: "text/plain"});
var reader = new FileReader();
reader.onload = this.step_func_done(function() {
assert_equals(reader.result, data);
});
reader.onerror = this.unreached_func("Unexpected error event");
reader.readAsText(blob);
}, "Create Blob in Worker");
promise_test(async () => {
const data = "TEST";
const blob = new Blob([data], {type: "text/plain"});
assert_equals(await blob.text(), data);
}, 'Create Blob in Worker');
done();
-42
View File
@@ -1,42 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Blob slice overflow</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://w3c.github.io/FileAPI/#dfn-slice">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var text = '';
for (var i = 0; i < 2000; ++i) {
text += 'A';
}
test(function() {
var blob = new Blob([text]);
var sliceBlob = blob.slice(-1, blob.size);
assert_equals(sliceBlob.size, 1, "Blob slice size");
}, "slice start is negative, relativeStart will be max((size + start), 0)");
test(function() {
var blob = new Blob([text]);
var sliceBlob = blob.slice(blob.size + 1, blob.size);
assert_equals(sliceBlob.size, 0, "Blob slice size");
}, "slice start is greater than blob size, relativeStart will be min(start, size)");
test(function() {
var blob = new Blob([text]);
var sliceBlob = blob.slice(blob.size - 2, -1);
assert_equals(sliceBlob.size, 1, "Blob slice size");
}, "slice end is negative, relativeEnd will be max((size + end), 0)");
test(function() {
var blob = new Blob([text]);
var sliceBlob = blob.slice(blob.size - 2, blob.size + 999);
assert_equals(sliceBlob.size, 2, "Blob slice size");
}, "slice end is greater than blob size, relativeEnd will be min(end, size)");
</script>
-238
View File
@@ -1,238 +0,0 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Blob slice</title>
<link rel=help href="https://w3c.github.io/FileAPI/#slice-method-algo">
<link rel=author title="Saurabh Anand" href="mailto:saurabhanandiit@gmail.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/Blob.js"></script>
<div id="log"></div>
<script>
test_blob(function() {
var blobTemp = new Blob(["PASS"]);
return blobTemp.slice();
}, {
expected: "PASS",
type: "",
desc: "no-argument Blob slice"
});
test(function() {
var blob1, blob2;
test_blob(function() {
return blob1 = new Blob(["squiggle"]);
}, {
expected: "squiggle",
type: "",
desc: "blob1."
});
test_blob(function() {
return blob2 = new Blob(["steak"], {type: "content/type"});
}, {
expected: "steak",
type: "content/type",
desc: "blob2."
});
test_blob(function() {
return new Blob().slice(0,0,null);
}, {
expected: "",
type: "null",
desc: "null type Blob slice"
});
test_blob(function() {
return new Blob().slice(0,0,undefined);
}, {
expected: "",
type: "",
desc: "undefined type Blob slice"
});
test_blob(function() {
return new Blob().slice(0,0);
}, {
expected: "",
type: "",
desc: "no type Blob slice"
});
var arrayBuffer = new ArrayBuffer(16);
var int8View = new Int8Array(arrayBuffer);
for (var i = 0; i < 16; i++) {
int8View[i] = i + 65;
}
var testData = [
[
["PASSSTRING"],
[{start: -6, contents: "STRING"},
{start: -12, contents: "PASSSTRING"},
{start: 4, contents: "STRING"},
{start: 12, contents: ""},
{start: 0, end: -6, contents: "PASS"},
{start: 0, end: -12, contents: ""},
{start: 0, end: 4, contents: "PASS"},
{start: 0, end: 12, contents: "PASSSTRING"},
{start: 7, end: 4, contents: ""}]
],
// Test 3 strings
[
["foo", "bar", "baz"],
[{start: 0, end: 9, contents: "foobarbaz"},
{start: 0, end: 3, contents: "foo"},
{start: 3, end: 9, contents: "barbaz"},
{start: 6, end: 9, contents: "baz"},
{start: 6, end: 12, contents: "baz"},
{start: 0, end: 9, contents: "foobarbaz"},
{start: 0, end: 11, contents: "foobarbaz"},
{start: 10, end: 15, contents: ""}]
],
// Test string, Blob, string
[
["foo", blob1, "baz"],
[{start: 0, end: 3, contents: "foo"},
{start: 3, end: 11, contents: "squiggle"},
{start: 2, end: 4, contents: "os"},
{start: 10, end: 12, contents: "eb"}]
],
// Test blob, string, blob
[
[blob1, "foo", blob1],
[{start: 0, end: 8, contents: "squiggle"},
{start: 7, end: 9, contents: "ef"},
{start: 10, end: 12, contents: "os"},
{start: 1, end: 4, contents: "qui"},
{start: 12, end: 15, contents: "qui"},
{start: 40, end: 60, contents: ""}]
],
// Test blobs all the way down
[
[blob2, blob1, blob2],
[{start: 0, end: 5, contents: "steak"},
{start: 5, end: 13, contents: "squiggle"},
{start: 13, end: 18, contents: "steak"},
{start: 1, end: 3, contents: "te"},
{start: 6, end: 10, contents: "quig"}]
],
// Test an ArrayBufferView
[
[int8View, blob1, "foo"],
[{start: 0, end: 8, contents: "ABCDEFGH"},
{start: 8, end: 18, contents: "IJKLMNOPsq"},
{start: 17, end: 20, contents: "qui"},
{start: 4, end: 12, contents: "EFGHIJKL"}]
],
// Test a partial ArrayBufferView
[
[new Uint8Array(arrayBuffer, 3, 5), blob1, "foo"],
[{start: 0, end: 8, contents: "DEFGHsqu"},
{start: 8, end: 18, contents: "igglefoo"},
{start: 4, end: 12, contents: "Hsquiggl"}]
],
// Test type coercion of a number
[
[3, int8View, "foo"],
[{start: 0, end: 8, contents: "3ABCDEFG"},
{start: 8, end: 18, contents: "HIJKLMNOPf"},
{start: 17, end: 21, contents: "foo"},
{start: 4, end: 12, contents: "DEFGHIJK"}]
],
[
[(new Uint8Array([0, 255, 0])).buffer,
new Blob(['abcd']),
'efgh',
'ijklmnopqrstuvwxyz'],
[{start: 1, end: 4, contents: "\uFFFD\u0000a"},
{start: 4, end: 8, contents: "bcde"},
{start: 8, end: 12, contents: "fghi"},
{start: 1, end: 12, contents: "\uFFFD\u0000abcdefghi"}]
]
];
testData.forEach(function(data, i) {
var blobs = data[0];
var tests = data[1];
tests.forEach(function(expectations, j) {
test(function() {
var blob = new Blob(blobs);
assert_true(blob instanceof Blob);
assert_false(blob instanceof File);
test_blob(function() {
return expectations.end === undefined
? blob.slice(expectations.start)
: blob.slice(expectations.start, expectations.end);
}, {
expected: expectations.contents,
type: "",
desc: "Slicing test: slice (" + i + "," + j + ")."
});
}, "Slicing test (" + i + "," + j + ").");
});
});
}, "Slices");
var invalidTypes = [
"\xFF",
"te\x09xt/plain",
"te\x00xt/plain",
"te\x1Fxt/plain",
"te\x7Fxt/plain"
];
invalidTypes.forEach(function(type) {
test_blob(function() {
var blob = new Blob(["PASS"]);
return blob.slice(0, 4, type);
}, {
expected: "PASS",
type: "",
desc: "Invalid contentType (" + format_value(type) + ")"
});
});
var validTypes = [
"te(xt/plain",
"te)xt/plain",
"te<xt/plain",
"te>xt/plain",
"te@xt/plain",
"te,xt/plain",
"te;xt/plain",
"te:xt/plain",
"te\\xt/plain",
"te\"xt/plain",
"te/xt/plain",
"te[xt/plain",
"te]xt/plain",
"te?xt/plain",
"te=xt/plain",
"te{xt/plain",
"te}xt/plain",
"te\x20xt/plain",
"TEXT/PLAIN",
"text/plain;charset = UTF-8",
"text/plain;charset=UTF-8"
];
validTypes.forEach(function(type) {
test_blob(function() {
var blob = new Blob(["PASS"]);
return blob.slice(0, 4, type);
}, {
expected: "PASS",
type: type.toLowerCase(),
desc: "Valid contentType (" + format_value(type) + ")"
});
});
</script>
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<script type="module">
let a = new Blob(['', '', undefined], { })
let b = a.stream()
let c = new ReadableStreamBYOBReader(b)
let d = new Int16Array(8)
await c.read(d)
c.releaseLock()
await a.text()
await b.cancel()
</script>
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<script>
const blob = new Blob([1, 2]);
const readable = blob.stream()
const writable = new WritableStream({}, {
size() {
let xhr = new XMLHttpRequest()
xhr.open("POST", "1", false)
xhr.send()
}
})
readable.pipeThrough({ readable, writable })
</script>
+19 -8
View File
@@ -1,24 +1,26 @@
// META: title=Blob Stream
// META: script=../support/Blob.js
// META: script=../../streams/resources/test-utils.js
// META: script=/common/gc.js
'use strict';
// Helper function that triggers garbage collection while reading a chunk
// if perform_gc is true.
async function read_and_gc(reader, perform_gc) {
const read_promise = reader.read();
if (perform_gc)
garbageCollect();
// Passing Uint8Array for byte streams; non-byte streams will simply ignore it
const read_promise = reader.read(new Uint8Array(64));
if (perform_gc) {
await garbageCollect();
}
return read_promise;
}
// Takes in a ReadableStream and reads from it until it is done, returning
// an array that contains the results of each read operation. If perform_gc
// is true, garbage collection is triggered while reading every chunk.
async function read_all_chunks(stream, perform_gc = false) {
async function read_all_chunks(stream, { perform_gc = false, mode } = {}) {
assert_true(stream instanceof ReadableStream);
assert_true('getReader' in stream);
const reader = stream.getReader();
const reader = stream.getReader({ mode });
assert_true('read' in reader);
let read_value = await read_and_gc(reader, perform_gc);
@@ -65,8 +67,17 @@ promise_test(async() => {
let blob = new Blob([typed_arr]);
const stream = blob.stream();
blob = null;
garbageCollect();
const chunks = await read_all_chunks(stream, /*perform_gc=*/true);
await garbageCollect();
const chunks = await read_all_chunks(stream, { perform_gc: true });
assert_array_equals(chunks, input_arr);
}, "Blob.stream() garbage collection of blob shouldn't break stream" +
"consumption")
promise_test(async () => {
const input_arr = [8, 241, 48, 123, 151];
const typed_arr = new Uint8Array(input_arr);
let blob = new Blob([typed_arr]);
const stream = blob.stream();
const chunks = await read_all_chunks(stream, { mode: "byob" });
assert_array_equals(chunks, input_arr);
}, "Reading Blob.stream() with BYOB reader")
-159
View File
@@ -1,159 +0,0 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>File constructor</title>
<link rel=help href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-file">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
const to_string_obj = { toString: () => 'a string' };
const to_string_throws = { toString: () => { throw new Error('expected'); } };
test(function() {
assert_true("File" in window, "window should have a File property.");
}, "File interface object exists");
test(t => {
assert_throws_js(TypeError, () => new File(),
'Bits argument is required');
assert_throws_js(TypeError, () => new File([]),
'Name argument is required');
}, 'Required arguments');
function test_first_argument(arg1, expectedSize, testName) {
test(function() {
var file = new File(arg1, "dummy");
assert_true(file instanceof File);
assert_equals(file.name, "dummy");
assert_equals(file.size, expectedSize);
assert_equals(file.type, "");
// assert_false(file.isClosed); XXX: File.isClosed doesn't seem to be implemented
assert_not_equals(file.lastModified, "");
}, testName);
}
test_first_argument([], 0, "empty fileBits");
test_first_argument(["bits"], 4, "DOMString fileBits");
test_first_argument(["𝓽𝓮𝔁𝓽"], 16, "Unicode DOMString fileBits");
test_first_argument([new String('string object')], 13, "String object fileBits");
test_first_argument([new Blob()], 0, "Empty Blob fileBits");
test_first_argument([new Blob(["bits"])], 4, "Blob fileBits");
test_first_argument([new File([], 'world.txt')], 0, "Empty File fileBits");
test_first_argument([new File(["bits"], 'world.txt')], 4, "File fileBits");
test_first_argument([new ArrayBuffer(8)], 8, "ArrayBuffer fileBits");
test_first_argument([new Uint8Array([0x50, 0x41, 0x53, 0x53])], 4, "Typed array fileBits");
test_first_argument(["bits", new Blob(["bits"]), new Blob(), new Uint8Array([0x50, 0x41]),
new Uint16Array([0x5353]), new Uint32Array([0x53534150])], 16, "Various fileBits");
test_first_argument([12], 2, "Number in fileBits");
test_first_argument([[1,2,3]], 5, "Array in fileBits");
test_first_argument([{}], 15, "Object in fileBits"); // "[object Object]"
test_first_argument([document.body], 24, "HTMLBodyElement in fileBits"); // "[object HTMLBodyElement]"
test_first_argument([to_string_obj], 8, "Object with toString in fileBits");
test_first_argument({[Symbol.iterator]() {
let i = 0;
return {next: () => [
{done:false, value:'ab'},
{done:false, value:'cde'},
{done:true}
][i++]};
}}, 5, 'Custom @@iterator');
[
'hello',
0,
null
].forEach(arg => {
test(t => {
assert_throws_js(TypeError, () => new File(arg, 'world.html'),
'Constructor should throw for invalid bits argument');
}, `Invalid bits argument: ${JSON.stringify(arg)}`);
});
test(t => {
assert_throws_js(Error, () => new File([to_string_throws], 'name.txt'),
'Constructor should propagate exceptions');
}, 'Bits argument: object that throws');
function test_second_argument(arg2, expectedFileName, testName) {
test(function() {
var file = new File(["bits"], arg2);
assert_true(file instanceof File);
assert_equals(file.name, expectedFileName);
}, testName);
}
test_second_argument("dummy", "dummy", "Using fileName");
test_second_argument("dummy/foo", "dummy/foo",
"No replacement when using special character in fileName");
test_second_argument(null, "null", "Using null fileName");
test_second_argument(1, "1", "Using number fileName");
test_second_argument('', '', "Using empty string fileName");
test_second_argument(document.body, '[object HTMLBodyElement]', "Using object fileName");
// testing the third argument
[
{type: 'text/plain', expected: 'text/plain'},
{type: 'text/plain;charset=UTF-8', expected: 'text/plain;charset=utf-8'},
{type: 'TEXT/PLAIN', expected: 'text/plain'},
{type: '𝓽𝓮𝔁𝓽/𝔭𝔩𝔞𝔦𝔫', expected: ''},
{type: 'ascii/nonprintable\u001F', expected: ''},
{type: 'ascii/nonprintable\u007F', expected: ''},
{type: 'nonascii\u00EE', expected: ''},
{type: 'nonascii\u1234', expected: ''},
{type: 'nonparsable', expected: 'nonparsable'}
].forEach(testCase => {
test(t => {
var file = new File(["bits"], "dummy", { type: testCase.type});
assert_true(file instanceof File);
assert_equals(file.type, testCase.expected);
}, `Using type in File constructor: ${testCase.type}`);
});
test(function() {
var file = new File(["bits"], "dummy", { lastModified: 42 });
assert_true(file instanceof File);
assert_equals(file.lastModified, 42);
}, "Using lastModified");
test(function() {
var file = new File(["bits"], "dummy", { name: "foo" });
assert_true(file instanceof File);
assert_equals(file.name, "dummy");
}, "Misusing name");
test(function() {
var file = new File(["bits"], "dummy", { unknownKey: "value" });
assert_true(file instanceof File);
assert_equals(file.name, "dummy");
}, "Unknown properties are ignored");
[
123,
123.4,
true,
'abc'
].forEach(arg => {
test(t => {
assert_throws_js(TypeError, () => new File(['bits'], 'name.txt', arg),
'Constructor should throw for invalid property bag type');
}, `Invalid property bag: ${JSON.stringify(arg)}`);
});
[
null,
undefined,
[1,2,3],
/regex/,
function() {}
].forEach(arg => {
test(t => {
assert_equals(new File(['bits'], 'name.txt', arg).size, 4,
'Constructor should accept object-ish property bag type');
}, `Unusual but valid property bag: ${arg}`);
});
test(t => {
assert_throws_js(Error,
() => new File(['bits'], 'name.txt', {type: to_string_throws}),
'Constructor should propagate exceptions');
}, 'Property bag propagates exceptions');
</script>
@@ -1,117 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Upload files named using controls (tentative)</title>
<!--
NOTE: This test is tentative because encoding for filename
control characters is not yet standardized.
-->
<link
rel="help"
href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"
/>
<link
rel="help"
href="https://html.spec.whatwg.org/multipage/dnd.html#datatransferitemlist"
/>
<link rel="help" href="https://w3c.github.io/FileAPI/#file-constructor" />
<link
rel="author"
title="Benjamin C. Wiley Sittler"
href="mailto:bsittler@chromium.org"
/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/send-file-form-helper.js"></script>
<script>
"use strict";
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-NUL-[\0].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-NUL-[\0].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-BS-[\b].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-BS-[\b].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-VT-[\v].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-VT-[\v].txt",
});
// These have characters that undergo processing in name=,
// filename=, and/or value; formPostFileUploadTest postprocesses
// expectedEncodedBaseName for these internally.
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-LF-[\n].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-LF-[\n].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-LF-CR-[\n\r].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-LF-CR-[\n\r].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-CR-[\r].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-CR-[\r].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-CR-LF-[\r\n].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-CR-LF-[\r\n].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-HT-[\t].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-HT-[\t].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-FF-[\f].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-FF-[\f].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-DEL-[\x7F].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-DEL-[\x7F].txt",
});
// The rest should be passed through unmodified:
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-ESC-[\x1B].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-ESC-[\x1B].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-SPACE-[ ].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-SPACE-[ ].txt",
});
</script>
@@ -1,72 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<meta name=timeout content=long>
<title>Upload files in ISO-2022-JP form (tentative)</title>
<!--
NOTE: This test is tentative because encoding for filename
characters unrepresentable in the form charset is not yet
standardized.
-->
<link rel="help"
href="https://github.com/whatwg/html/issues/3223">
<link rel="help"
href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data">
<link rel="help"
href="https://html.spec.whatwg.org/multipage/dnd.html#datatransferitemlist">
<link rel="help"
href="https://w3c.github.io/FileAPI/#file-constructor">
<link rel="author" title="Benjamin C. Wiley Sittler"
href="mailto:bsittler@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/send-file-form-helper.js"></script>
<script>
'use strict';
formPostFileUploadTest({
fileNameSource: 'ASCII',
fileBaseName: 'file-for-upload-in-form.txt',
formEncoding: 'ISO-2022-JP',
expectedEncodedBaseName: 'file-for-upload-in-form.txt',
});
formPostFileUploadTest({
fileNameSource: 'x-user-defined',
fileBaseName: 'file-for-upload-in-form-\uF7F0\uF793\uF783\uF7A0.txt',
formEncoding: 'ISO-2022-JP',
expectedEncodedBaseName: (
'file-for-upload-in-form-&#63472;&#63379;&#63363;&#63392;.txt'),
});
formPostFileUploadTest({
fileNameSource: 'windows-1252',
fileBaseName: 'file-for-upload-in-form-☺😂.txt',
formEncoding: 'ISO-2022-JP',
expectedEncodedBaseName: (
'file-for-upload-in-form-&#226;&#732;&#186;&#240;&#376;&#732;&#8218;.txt'),
});
formPostFileUploadTest({
fileNameSource: 'JIS X 0201 and JIS X 0208',
fileBaseName: 'file-for-upload-in-form-★星★.txt',
formEncoding: 'ISO-2022-JP',
expectedEncodedBaseName: 'file-for-upload-in-form-\x1B$B!z@1!z\x1B(B.txt',
});
formPostFileUploadTest({
fileNameSource: 'Unicode',
fileBaseName: 'file-for-upload-in-form-☺😂.txt',
formEncoding: 'ISO-2022-JP',
expectedEncodedBaseName: 'file-for-upload-in-form-&#9786;&#128514;.txt',
});
formPostFileUploadTest({
fileNameSource: 'Unicode',
fileBaseName: `file-for-upload-in-form-${kTestChars}.txt`,
formEncoding: 'ISO-2022-JP',
expectedEncodedBaseName: `file-for-upload-in-form-${
kTestFallbackIso2022jp
}.txt`,
});
</script>
@@ -1,230 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Upload files named using punctuation (tentative)</title>
<!--
NOTE: This test is tentative because encoding for filename
punctuation characters is not yet standardized.
-->
<link
rel="help"
href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"
/>
<link
rel="help"
href="https://html.spec.whatwg.org/multipage/dnd.html#datatransferitemlist"
/>
<link rel="help" href="https://w3c.github.io/FileAPI/#file-constructor" />
<link
rel="author"
title="Benjamin C. Wiley Sittler"
href="mailto:bsittler@chromium.org"
/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/send-file-form-helper.js"></script>
<script>
"use strict";
// These have characters that undergo processing in name=,
// filename=, and/or value; formPostFileUploadTest postprocesses
// expectedEncodedBaseName for these internally.
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-QUOTATION-MARK-[\x22].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName:
"file-for-upload-in-form-QUOTATION-MARK-[\x22].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: '"file-for-upload-in-form-double-quoted.txt"',
formEncoding: "UTF-8",
expectedEncodedBaseName: '"file-for-upload-in-form-double-quoted.txt"',
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-REVERSE-SOLIDUS-[\\].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName:
"file-for-upload-in-form-REVERSE-SOLIDUS-[\\].txt",
});
// The rest should be passed through unmodified:
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-EXCLAMATION-MARK-[!].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-EXCLAMATION-MARK-[!].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-DOLLAR-SIGN-[$].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-DOLLAR-SIGN-[$].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-PERCENT-SIGN-[%].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-PERCENT-SIGN-[%].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-AMPERSAND-[&].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-AMPERSAND-[&].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-APOSTROPHE-['].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-APOSTROPHE-['].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-LEFT-PARENTHESIS-[(].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-LEFT-PARENTHESIS-[(].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-RIGHT-PARENTHESIS-[)].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName:
"file-for-upload-in-form-RIGHT-PARENTHESIS-[)].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-ASTERISK-[*].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-ASTERISK-[*].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-PLUS-SIGN-[+].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-PLUS-SIGN-[+].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-COMMA-[,].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-COMMA-[,].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-FULL-STOP-[.].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-FULL-STOP-[.].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-SOLIDUS-[/].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-SOLIDUS-[/].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-COLON-[:].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-COLON-[:].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-SEMICOLON-[;].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-SEMICOLON-[;].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-EQUALS-SIGN-[=].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-EQUALS-SIGN-[=].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-QUESTION-MARK-[?].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-QUESTION-MARK-[?].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-CIRCUMFLEX-ACCENT-[^].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName:
"file-for-upload-in-form-CIRCUMFLEX-ACCENT-[^].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-LEFT-SQUARE-BRACKET-[[].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName:
"file-for-upload-in-form-LEFT-SQUARE-BRACKET-[[].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-RIGHT-SQUARE-BRACKET-[]].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName:
"file-for-upload-in-form-RIGHT-SQUARE-BRACKET-[]].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-LEFT-CURLY-BRACKET-[{].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName:
"file-for-upload-in-form-LEFT-CURLY-BRACKET-[{].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-VERTICAL-LINE-[|].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-VERTICAL-LINE-[|].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-RIGHT-CURLY-BRACKET-[}].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName:
"file-for-upload-in-form-RIGHT-CURLY-BRACKET-[}].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-TILDE-[~].txt",
formEncoding: "UTF-8",
expectedEncodedBaseName: "file-for-upload-in-form-TILDE-[~].txt",
});
formPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "'file-for-upload-in-form-single-quoted.txt'",
formEncoding: "UTF-8",
expectedEncodedBaseName: "'file-for-upload-in-form-single-quoted.txt'",
});
</script>
@@ -1,69 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Upload files in Windows-1252 form (tentative)</title>
<!--
NOTE: This test is tentative because encoding for filename
characters unrepresentable in the form charset is not yet
standardized.
-->
<link rel="help"
href="https://github.com/whatwg/html/issues/3223">
<link rel="help"
href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data">
<link rel="help"
href="https://html.spec.whatwg.org/multipage/dnd.html#datatransferitemlist">
<link rel="help"
href="https://w3c.github.io/FileAPI/#file-constructor">
<link rel="author" title="Benjamin C. Wiley Sittler"
href="mailto:bsittler@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/send-file-form-helper.js"></script>
<script>
'use strict';
formPostFileUploadTest({
fileNameSource: 'ASCII',
fileBaseName: 'file-for-upload-in-form.txt',
formEncoding: 'windows-1252',
expectedEncodedBaseName: 'file-for-upload-in-form.txt',
});
formPostFileUploadTest({
fileNameSource: 'x-user-defined',
fileBaseName: 'file-for-upload-in-form-\uF7F0\uF793\uF783\uF7A0.txt',
formEncoding: 'windows-1252',
expectedEncodedBaseName: 'file-for-upload-in-form-&#63472;&#63379;&#63363;&#63392;.txt',
});
formPostFileUploadTest({
fileNameSource: 'windows-1252',
fileBaseName: 'file-for-upload-in-form-☺😂.txt',
formEncoding: 'windows-1252',
expectedEncodedBaseName: 'file-for-upload-in-form-\xE2\x98\xBA\xF0\x9F\x98\x82.txt',
});
formPostFileUploadTest({
fileNameSource: 'JIS X 0201 and JIS X 0208',
fileBaseName: 'file-for-upload-in-form-★星★.txt',
formEncoding: 'windows-1252',
expectedEncodedBaseName: 'file-for-upload-in-form-&#9733;&#26143;&#9733;.txt',
});
formPostFileUploadTest({
fileNameSource: 'Unicode',
fileBaseName: 'file-for-upload-in-form-☺😂.txt',
formEncoding: 'windows-1252',
expectedEncodedBaseName: 'file-for-upload-in-form-&#9786;&#128514;.txt',
});
formPostFileUploadTest({
fileNameSource: 'Unicode',
fileBaseName: `file-for-upload-in-form-${kTestChars}.txt`,
formEncoding: 'windows-1252',
expectedEncodedBaseName: `file-for-upload-in-form-${
kTestFallbackWindows1252
}.txt`,
});
</script>
@@ -1,70 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Upload files in x-user-defined form (tentative)</title>
<!--
NOTE: This test is tentative because encoding for filename
characters unrepresentable in the form charset is not yet
standardized.
-->
<link rel="help"
href="https://github.com/whatwg/html/issues/3223">
<link rel="help"
href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data">
<link rel="help"
href="https://html.spec.whatwg.org/multipage/dnd.html#datatransferitemlist">
<link rel="help"
href="https://w3c.github.io/FileAPI/#file-constructor">
<link rel="author" title="Benjamin C. Wiley Sittler"
href="mailto:bsittler@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/send-file-form-helper.js"></script>
<script>
'use strict';
formPostFileUploadTest({
fileNameSource: 'ASCII',
fileBaseName: 'file-for-upload-in-form.txt',
formEncoding: 'x-user-defined',
expectedEncodedBaseName: 'file-for-upload-in-form.txt',
});
formPostFileUploadTest({
fileNameSource: 'x-user-defined',
fileBaseName: 'file-for-upload-in-form-\uF7F0\uF793\uF783\uF7A0.txt',
formEncoding: 'x-user-defined',
expectedEncodedBaseName: 'file-for-upload-in-form-\xF0\x93\x83\xA0.txt',
});
formPostFileUploadTest({
fileNameSource: 'windows-1252',
fileBaseName: 'file-for-upload-in-form-☺😂.txt',
formEncoding: 'x-user-defined',
expectedEncodedBaseName: ('file-for-upload-in-form-' +
'&#226;&#732;&#186;&#240;&#376;&#732;&#8218;.txt'),
});
formPostFileUploadTest({
fileNameSource: 'JIS X 0201 and JIS X 0208',
fileBaseName: 'file-for-upload-in-form-★星★.txt',
formEncoding: 'x-user-defined',
expectedEncodedBaseName: 'file-for-upload-in-form-&#9733;&#26143;&#9733;.txt',
});
formPostFileUploadTest({
fileNameSource: 'Unicode',
fileBaseName: 'file-for-upload-in-form-☺😂.txt',
formEncoding: 'x-user-defined',
expectedEncodedBaseName: 'file-for-upload-in-form-&#9786;&#128514;.txt',
});
formPostFileUploadTest({
fileNameSource: 'Unicode',
fileBaseName: `file-for-upload-in-form-${kTestChars}.txt`,
formEncoding: 'x-user-defined',
expectedEncodedBaseName: `file-for-upload-in-form-${
kTestFallbackXUserDefined
}.txt`,
});
</script>
@@ -1,93 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>FormData: Upload files named using controls (tentative)</title>
<!--
NOTE: This test is tentative because encoding for filename
control characters is not yet standardized.
-->
<link
rel="help"
href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"
/>
<link
rel="help"
href="https://html.spec.whatwg.org/multipage/dnd.html#datatransferitemlist"
/>
<link rel="help" href="https://w3c.github.io/FileAPI/#file-constructor" />
<link
rel="author"
title="Benjamin C. Wiley Sittler"
href="mailto:bsittler@chromium.org"
/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/send-file-formdata-helper.js"></script>
<script>
"use strict";
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-NUL-[\0].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-BS-[\b].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-VT-[\v].txt",
});
// These have characters that undergo processing in name=,
// filename=, and/or value; formDataPostFileUploadTest postprocesses
// expectedEncodedBaseName for these internally.
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-LF-[\n].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-LF-CR-[\n\r].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-CR-[\r].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-CR-LF-[\r\n].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-HT-[\t].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-FF-[\f].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-DEL-[\x7F].txt",
});
// The rest should be passed through unmodified:
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-ESC-[\x1B].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-SPACE-[ ].txt",
});
</script>
@@ -1,168 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>FormData: Upload files named using punctuation (tentative)</title>
<!--
NOTE: This test is tentative because encoding for filename
punctuation characters is not yet standardized.
-->
<link
rel="help"
href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"
/>
<link
rel="help"
href="https://html.spec.whatwg.org/multipage/dnd.html#datatransferitemlist"
/>
<link rel="help" href="https://w3c.github.io/FileAPI/#file-constructor" />
<link
rel="author"
title="Benjamin C. Wiley Sittler"
href="mailto:bsittler@chromium.org"
/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/send-file-formdata-helper.js"></script>
<script>
"use strict";
// These have characters that undergo processing in name=,
// filename=, and/or value; formDataPostFileUploadTest postprocesses
// expectedEncodedBaseName for these internally.
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-QUOTATION-MARK-[\x22].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: '"file-for-upload-in-form-double-quoted.txt"',
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-REVERSE-SOLIDUS-[\\].txt",
});
// The rest should be passed through unmodified:
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-EXCLAMATION-MARK-[!].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-DOLLAR-SIGN-[$].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-PERCENT-SIGN-[%].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-AMPERSAND-[&].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-APOSTROPHE-['].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-LEFT-PARENTHESIS-[(].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-RIGHT-PARENTHESIS-[)].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-ASTERISK-[*].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-PLUS-SIGN-[+].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-COMMA-[,].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-FULL-STOP-[.].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-SOLIDUS-[/].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-COLON-[:].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-SEMICOLON-[;].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-EQUALS-SIGN-[=].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-QUESTION-MARK-[?].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-CIRCUMFLEX-ACCENT-[^].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-LEFT-SQUARE-BRACKET-[[].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-RIGHT-SQUARE-BRACKET-[]].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-LEFT-CURLY-BRACKET-[{].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-VERTICAL-LINE-[|].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-RIGHT-CURLY-BRACKET-[}].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form-TILDE-[~].txt",
});
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "'file-for-upload-in-form-single-quoted.txt'",
});
</script>
@@ -1,53 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>FormData: Upload files in UTF-8 fetch()</title>
<link
rel="help"
href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"
/>
<link
rel="help"
href="https://html.spec.whatwg.org/multipage/dnd.html#datatransferitemlist"
/>
<link rel="help" href="https://w3c.github.io/FileAPI/#file-constructor" />
<link
rel="author"
title="Benjamin C. Wiley Sittler"
href="mailto:bsittler@chromium.org"
/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/send-file-formdata-helper.js"></script>
<script>
"use strict";
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form.txt",
});
formDataPostFileUploadTest({
fileNameSource: "x-user-defined",
fileBaseName: "file-for-upload-in-form-\uF7F0\uF793\uF783\uF7A0.txt",
});
formDataPostFileUploadTest({
fileNameSource: "windows-1252",
fileBaseName: "file-for-upload-in-form-☺😂.txt",
});
formDataPostFileUploadTest({
fileNameSource: "JIS X 0201 and JIS X 0208",
fileBaseName: "file-for-upload-in-form-★星★.txt",
});
formDataPostFileUploadTest({
fileNameSource: "Unicode",
fileBaseName: "file-for-upload-in-form-☺😂.txt",
});
formDataPostFileUploadTest({
fileNameSource: "Unicode",
fileBaseName: `file-for-upload-in-form-${kTestChars}.txt`,
});
</script>
-28
View File
@@ -1,28 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>FormData: Upload ASCII-named file in UTF-8 form</title>
<link
rel="help"
href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data"
/>
<link
rel="help"
href="https://html.spec.whatwg.org/multipage/dnd.html#datatransferitemlist"
/>
<link rel="help" href="https://w3c.github.io/FileAPI/#file-constructor" />
<link
rel="author"
title="Benjamin C. Wiley Sittler"
href="mailto:bsittler@chromium.org"
/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/send-file-formdata-helper.js"></script>
<script>
"use strict";
formDataPostFileUploadTest({
fileNameSource: "ASCII",
fileBaseName: "file-for-upload-in-form.txt",
});
</script>
+59
View File
@@ -0,0 +1,59 @@
// META: title=FileReader States
'use strict';
test(function () {
assert_true(
"FileReader" in globalThis,
"globalThis should have a FileReader property.",
);
}, "FileReader interface object");
test(function () {
var fileReader = new FileReader();
assert_true(fileReader instanceof FileReader);
}, "no-argument FileReader constructor");
var t_abort = async_test("FileReader States -- abort");
t_abort.step(function () {
var fileReader = new FileReader();
assert_equals(fileReader.readyState, 0);
assert_equals(fileReader.readyState, FileReader.EMPTY);
var blob = new Blob();
fileReader.readAsArrayBuffer(blob);
assert_equals(fileReader.readyState, 1);
assert_equals(fileReader.readyState, FileReader.LOADING);
fileReader.onabort = this.step_func(function (e) {
assert_equals(fileReader.readyState, 2);
assert_equals(fileReader.readyState, FileReader.DONE);
t_abort.done();
});
fileReader.abort();
fileReader.onabort = this.unreached_func("abort event should fire sync");
});
var t_event = async_test("FileReader States -- events");
t_event.step(function () {
var fileReader = new FileReader();
var blob = new Blob();
fileReader.readAsArrayBuffer(blob);
fileReader.onloadstart = this.step_func(function (e) {
assert_equals(fileReader.readyState, 1);
assert_equals(fileReader.readyState, FileReader.LOADING);
});
fileReader.onprogress = this.step_func(function (e) {
assert_equals(fileReader.readyState, 1);
assert_equals(fileReader.readyState, FileReader.LOADING);
});
fileReader.onloadend = this.step_func(function (e) {
assert_equals(fileReader.readyState, 2);
assert_equals(fileReader.readyState, FileReader.DONE);
t_event.done();
});
});
-67
View File
@@ -1,67 +0,0 @@
<!doctype html>
<html>
<head>
<title>FileReader States</title>
<link rel=help href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-filereader">
<link rel=author title="Lenient" href="mailto:lenient315@gmail.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<script>
test(function() {
assert_true("FileReader" in window, "window should have a FileReader property.");
}, "FileReader interface object");
test(function(){
var fileReader = new FileReader();
assert_true(fileReader instanceof FileReader);
}, "no-argument FileReader constructor");
var t_abort = async_test("FileReader States -- abort");
t_abort.step(function(){
var fileReader = new FileReader();
assert_equals(fileReader.readyState, 0);
assert_equals(fileReader.readyState, FileReader.EMPTY);
var blob = new Blob();
fileReader.readAsArrayBuffer(blob);
assert_equals(fileReader.readyState, 1);
assert_equals(fileReader.readyState, FileReader.LOADING);
fileReader.onabort = this.step_func(function(e) {
assert_equals(fileReader.readyState, 2);
assert_equals(fileReader.readyState, FileReader.DONE);
t_abort.done();
});
fileReader.abort();
fileReader.onabort = this.unreached_func("abort event should fire sync")
});
var t_event = async_test("FileReader States -- events");
t_event.step(function(){
var fileReader = new FileReader();
var blob = new Blob();
fileReader.readAsArrayBuffer(blob);
fileReader.onloadstart = this.step_func(function(e) {
assert_equals(fileReader.readyState, 1);
assert_equals(fileReader.readyState, FileReader.LOADING);
});
fileReader.onprogress = this.step_func(function(e) {
assert_equals(fileReader.readyState, 1);
assert_equals(fileReader.readyState, FileReader.LOADING);
});
fileReader.onloadend = this.step_func(function(e) {
assert_equals(fileReader.readyState, 2);
assert_equals(fileReader.readyState, FileReader.DONE);
t_event.done();
});
});
</script>
</body>
</html>
+19
View File
@@ -0,0 +1,19 @@
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: timeout=long
'use strict';
// https://w3c.github.io/FileAPI/
idl_test(
['FileAPI'],
['dom', 'html', 'url'],
idl_array => {
idl_array.add_objects({
Blob: ['new Blob(["TEST"])'],
File: ['new File(["myFileBits"], "myFileName")'],
FileReader: ['new FileReader()']
});
}
);
+2 -5
View File
@@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>File API automated IDL tests</title>
<title>File API automated IDL tests (requiring dom)</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#conformance">
<script src="/resources/testharness.js"></script>
@@ -27,10 +27,7 @@
['dom', 'html', 'url'],
idl_array => {
idl_array.add_objects({
Blob: ['new Blob(["TEST"])'],
File: ['new File(["myFileBits"], "myFileName")'],
FileList: ['document.querySelector("#fileChooser").files'],
FileReader: ['new FileReader()']
FileList: ['document.querySelector("#fileChooser").files']
});
}
);
-3
View File
@@ -10,9 +10,6 @@ idl_test(
['dom', 'html', 'url'],
idl_array => {
idl_array.add_objects({
Blob: ['new Blob(["TEST"])'],
File: ['new File(["myFileBits"], "myFileName")'],
FileReader: ['new FileReader()'],
FileReaderSync: ['new FileReaderSync()']
});
}
@@ -1,13 +1,5 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>FileAPI Test: Blob Determining Encoding</title>
<link ref="author" title="march1993" href="mailto:march511@gmail.com">
<link rel=help href="http://dev.w3.org/2006/webapi/FileAPI/#enctype">
<link rel=help href="http://encoding.spec.whatwg.org/#decode">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
// META: title=FileAPI Test: Blob Determining Encoding
var t = async_test("Blob Determing Encoding with encoding argument");
t.step(function() {
// string 'hello'
@@ -87,5 +79,3 @@ t.step(function() {
reader.readAsText(blob);
});
</script>
@@ -1,10 +1,5 @@
<!doctype html>
<meta charset="utf-8">
<title>FileReader event handler attributes</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
// META: title=FileReader event handler attributes
var attributes = [
"onloadstart",
"onprogress",
@@ -20,4 +15,3 @@ attributes.forEach(function(a) {
"event handler attribute should initially be null");
}, "FileReader." + a + ": initial value");
});
</script>
@@ -1,11 +1,5 @@
<!DOCTYPE html>
<title>FileReader: starting new reads while one is in progress</title>
<link rel="author" title="Yinkan Li" href="mailto:liyinkan.biz@gmail.com">
<link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#MultipleReads">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
// META: title=FileReader: starting new reads while one is in progress
test(function() {
var blob_1 = new Blob(['TEST000000001'])
var blob_2 = new Blob(['TEST000000002'])
@@ -85,5 +79,3 @@ async_test(function() {
});
reader.readAsText(blob_1);
}, 'test abort and restart in onloadstart event for readAsText');
</script>
@@ -1,17 +1,5 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FileAPI Test: filereader_abort</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#abort">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
// META: title=FileAPI Test: filereader_abort
<script>
test(function() {
var readerNoRead = new FileReader();
readerNoRead.abort();
@@ -48,6 +36,3 @@
assert_equals(readerAbort.readyState, readerAbort.DONE);
});
}, "Aborting after read");
</script>
</body>
</html>
@@ -1,18 +1,5 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FileAPI Test: filereader_error</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-domerror">
<link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#abort">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
// META: title=FileAPI Test: filereader_error
<script>
async_test(function() {
var blob = new Blob(["TEST THE ERROR ATTRIBUTE AND ERROR EVENT"]);
var reader = new FileReader();
@@ -30,6 +17,3 @@
reader.readAsText(blob);
reader.abort();
});
</script>
</body>
</html>
@@ -1,17 +1,5 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FileAPI Test: filereader_readAsArrayBuffer</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#readAsArrayBuffer">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
// META: title=FileAPI Test: filereader_readAsArrayBuffer
<script>
async_test(function() {
var blob = new Blob(["TEST"]);
var reader = new FileReader();
@@ -33,6 +21,3 @@
reader.readAsArrayBuffer(blob);
});
</script>
</body>
</html>
@@ -1,11 +1,4 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>FileAPI Test: filereader_readAsBinaryString</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://w3c.github.io/FileAPI/#readAsBinaryString">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
// META: title=FileAPI Test: filereader_readAsBinaryString
async_test(t => {
const blob = new Blob(["σ"]);
@@ -28,5 +21,3 @@ async_test(t => {
reader.readAsBinaryString(blob);
});
</script>
@@ -1,12 +1,5 @@
<!doctype html>
<meta charset="utf-8">
<title>FileAPI Test: FileReader.readAsDataURL</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="https://w3c.github.io/FileAPI/#readAsDataURL">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
// META: title=FileAPI Test: FileReader.readAsDataURL
<script>
async_test(function(testCase) {
var blob = new Blob(["TEST"]);
var reader = new FileReader();
@@ -46,6 +39,4 @@ async_test(function(testCase) {
testCase.done();
});
reader.readAsDataURL(blob);
}, 'readAsDataURL result for Blob with unspecified MIME type');
</script>
}, 'readAsDataURL result for Blob with unspecified MIME type');
@@ -1,17 +1,5 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FileAPI Test: filereader_readAsText</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#readAsDataText">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
// META: title=FileAPI Test: filereader_readAsText
<script>
async_test(function() {
var blob = new Blob(["TEST"]);
var reader = new FileReader();
@@ -46,6 +34,3 @@
});
reader_UTF16.readAsText(blob, "UTF-16");
}, "readAsText should correctly read UTF-16.");
</script>
</body>
</html>
@@ -1,17 +1,5 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FileAPI Test: filereader_readystate</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#blobreader-state">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
// META: title=FileAPI Test: filereader_readystate
<script>
async_test(function() {
var blob = new Blob(["THIS TEST THE READYSTATE WHEN READ BLOB"]);
var reader = new FileReader();
@@ -29,6 +17,3 @@
reader.readAsDataURL(blob);
});
</script>
</body>
</html>
@@ -1,17 +1,5 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FileAPI Test: filereader_result</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#filedata-attr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
// META: title=FileAPI Test: filereader_result
<script>
var blob, blob2;
setup(function() {
blob = new Blob(["This test the result attribute"]);
@@ -92,6 +80,3 @@
}, 'result is null during "' + event + '" event for ' + method);
}
}
</script>
</body>
</html>
+2 -2
View File
@@ -1,6 +1,6 @@
'use strict'
function test_blob(fn, expectations) {
self.test_blob = (fn, expectations) => {
var expected = expectations.expected,
type = expectations.type,
desc = expectations.desc;
@@ -24,7 +24,7 @@ function test_blob(fn, expectations) {
});
}
function test_blob_binary(fn, expectations) {
self.test_blob_binary = (fn, expectations) => {
var expected = expectations.expected,
type = expectations.type,
desc = expectations.desc;
+3
View File
@@ -0,0 +1,3 @@
<!DOCTYPE html>
<meta charset="utf-8">
<body>
@@ -70,19 +70,21 @@ const formDataPostFileUploadTest = ({
}`,
);
const asName = fileBaseName.replace(/[\r\n"]/g, encodeURIComponent);
const asValue = fileBaseName.replace(/\r\n?|\n/g, "\r\n");
const asName = asValue.replace(/[\r\n"]/g, encodeURIComponent);
const asFilename = fileBaseName.replace(/[\r\n"]/g, encodeURIComponent);
const expectedText = [
boundary,
'Content-Disposition: form-data; name="filename"',
"",
fileBaseName,
asValue,
boundary,
`Content-Disposition: form-data; name="${asName}"`,
"",
"filename",
boundary,
`Content-Disposition: form-data; name="file"; ` +
`filename="${asName}"`,
`filename="${asFilename}"`,
"Content-Type: text/plain",
"",
kTestChars,
+3 -2
View File
@@ -2,6 +2,7 @@
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<body>
<script>
async_test(t => {
@@ -42,7 +43,7 @@ async_test(t => {
const url = URL.createObjectURL(blob);
const frame = document.createElement('iframe');
frame.setAttribute('style', 'display:none;');
frame.src = '//{{domains[www1]}}:{{location[port]}}/FileAPI/url/resources/revoke-helper.html';
frame.src = get_host_info().HTTP_REMOTE_ORIGIN + '/FileAPI/url/resources/revoke-helper.html';
document.body.appendChild(frame);
frame.onload = t.step_func(e => {
@@ -58,4 +59,4 @@ async_test(t => {
}));
}, 'It is not possible to revoke cross-origin blob URLs.');
</script>
</script>
+7 -1
View File
@@ -2,10 +2,16 @@
const blob = new Blob(['test']);
const file = new File(['test'], 'name');
test(() => {
test(t => {
const url_count = 5000;
let list = [];
t.add_cleanup(() => {
for (let url of list) {
URL.revokeObjectURL(url);
}
});
for (let i = 0; i < url_count; ++i)
list.push(URL.createObjectURL(blob));
+19
View File
@@ -1,4 +1,5 @@
// META: script=resources/fetch-tests.js
// META: script=/common/gc.js
function fetch_should_succeed(test, request) {
return fetch(request).then(response => response.text());
@@ -37,6 +38,24 @@ promise_test(t => {
});
}, 'Revoke blob URL after creating Request, will fetch');
promise_test(async t => {
const blob_contents = 'test blob contents';
const blob = new Blob([blob_contents]);
const url = URL.createObjectURL(blob);
let request = new Request(url);
// Revoke the object URL. Request should take a reference to the blob as
// soon as it receives it in open(), so the request succeeds even though we
// revoke the URL before calling fetch().
URL.revokeObjectURL(url);
request = request.clone();
await garbageCollect();
const text = await fetch_should_succeed(t, request);
assert_equals(text, blob_contents);
}, 'Revoke blob URL after creating Request, then clone Request, will fetch');
promise_test(function(t) {
const blob_contents = 'test blob contents';
const blob = new Blob([blob_contents]);
+5 -5
View File
@@ -10,14 +10,13 @@ See [test/wpt](../../wpt/README.md) for information on how these tests are run.
Last update:
- common: https://github.com/web-platform-tests/wpt/tree/03c5072aff/common
- common: https://github.com/web-platform-tests/wpt/tree/dbd648158d/common
- console: https://github.com/web-platform-tests/wpt/tree/767ae35464/console
- dom/abort: https://github.com/web-platform-tests/wpt/tree/8fadb38120/dom/abort
- dom/events: https://github.com/web-platform-tests/wpt/tree/ab8999891c/dom/events
- encoding: https://github.com/web-platform-tests/wpt/tree/0c1b9d1622/encoding
- fetch/data-urls/resources: https://github.com/web-platform-tests/wpt/tree/7c79d998ff/fetch/data-urls/resources
- FileAPI: https://github.com/web-platform-tests/wpt/tree/3b279420d4/FileAPI
- FileAPI/file: https://github.com/web-platform-tests/wpt/tree/c01f637cca/FileAPI/file
- FileAPI: https://github.com/web-platform-tests/wpt/tree/1e432c4550/FileAPI
- hr-time: https://github.com/web-platform-tests/wpt/tree/34cafd797e/hr-time
- html/webappapis/atob: https://github.com/web-platform-tests/wpt/tree/f267e1dca6/html/webappapis/atob
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/2c5c3c4c27/html/webappapis/microtask-queuing
@@ -26,14 +25,15 @@ Last update:
- interfaces: https://github.com/web-platform-tests/wpt/tree/df731dab88/interfaces
- performance-timeline: https://github.com/web-platform-tests/wpt/tree/17ebc3aea0/performance-timeline
- resource-timing: https://github.com/web-platform-tests/wpt/tree/22d38586d0/resource-timing
- resources: https://github.com/web-platform-tests/wpt/tree/fbf1e7d247/resources
- streams: https://github.com/web-platform-tests/wpt/tree/9e5ef42bd3/streams
- resources: https://github.com/web-platform-tests/wpt/tree/919874f84f/resources
- streams: https://github.com/web-platform-tests/wpt/tree/51750bc8d7/streams
- url: https://github.com/web-platform-tests/wpt/tree/1eaeb0e178/url
- user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/d8dbe6990b/wasm/jsapi
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/238d9d9bac/WebCryptoAPI
- webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions
- webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/e97fac4791/webmessaging/broadcastchannel
[Web Platform Tests]: https://github.com/web-platform-tests/wpt
[`git node wpt`]: https://github.com/nodejs/node-core-utils/blob/main/docs/git-node.md#git-node-wpt
+32
View File
@@ -0,0 +1,32 @@
const custom_cors_response = (payload, base_url) => {
base_url = base_url || new URL(location.href);
// Clone the given `payload` so that, as we modify it, we won't be mutating
// the caller's value in unexpected ways.
payload = Object.assign({}, payload);
payload.headers = payload.headers || {};
// Note that, in order to have out-of-the-box support for tests that don't
// call `setup({'allow_uncaught_exception': true})` we return a no-op JS
// payload. This approach will avoid hitting syntax errors if the resource is
// interpreted as script. Without this workaround, the SyntaxError would be
// caught by the test harness and trigger a test failure.
payload.content = payload.content || '/* custom-cors-response.js content */';
payload.status_code = payload.status_code || 200;
// Assume that we'll be doing a CORS-enabled fetch so we'll need to set ACAO.
const acao = "Access-Control-Allow-Origin";
if (!(acao in payload.headers)) {
payload.headers[acao] = '*';
}
if (!("Content-Type" in payload.headers)) {
payload.headers["Content-Type"] = "text/javascript";
}
let ret = new URL("/common/CustomCorsResponse.py", base_url);
for (const key in payload) {
ret.searchParams.append(key, JSON.stringify(payload[key]));
}
return ret;
};
+228
View File
@@ -0,0 +1,228 @@
# `RemoteContext`: API for script execution in another context
`RemoteContext` in `/common/dispatcher/dispatcher.js` provides an interface to
execute JavaScript in another global object (page or worker, the "executor"),
based on:
- [WPT RFC 88: context IDs from uuid searchParams in URL](https://github.com/web-platform-tests/rfcs/pull/88),
- [WPT RFC 89: execute_script](https://github.com/web-platform-tests/rfcs/pull/89) and
- [WPT RFC 91: RemoteContext](https://github.com/web-platform-tests/rfcs/pull/91).
Tests can send arbitrary javascript to executors to evaluate in its global
object, like:
```
// injector.html
const argOnLocalContext = ...;
async function execute() {
window.open('executor.html?uuid=' + uuid);
const ctx = new RemoteContext(uuid);
await ctx.execute_script(
(arg) => functionOnRemoteContext(arg),
[argOnLocalContext]);
};
```
and on executor:
```
// executor.html
function functionOnRemoteContext(arg) { ... }
const uuid = new URLSearchParams(window.location.search).get('uuid');
const executor = new Executor(uuid);
```
For concrete examples, see
[events.html](../../html/browsers/browsing-the-web/back-forward-cache/events.html)
and
[executor.html](../../html/browsers/browsing-the-web/back-forward-cache/resources/executor.html)
in back-forward cache tests.
Note that `executor*` files under `/common/dispatcher/` are NOT for
`RemoteContext.execute_script()`. Use `remote-executor.html` instead.
This is universal and avoids introducing many specific `XXX-helper.html`
resources.
Moreover, tests are easier to read, because the whole logic of the test can be
defined in a single file.
## `new RemoteContext(uuid)`
- `uuid` is a UUID string that identifies the remote context and should match
with the `uuid` parameter of the URL of the remote context.
- Callers should create the remote context outside this constructor (e.g.
`window.open('executor.html?uuid=' + uuid)`).
## `RemoteContext.execute_script(fn, args)`
- `fn` is a JavaScript function to execute on the remote context, which is
converted to a string using `toString()` and sent to the remote context.
- `args` is null or an array of arguments to pass to the function on the
remote context. Arguments are passed as JSON.
- If the return value of `fn` when executed in the remote context is a promise,
the promise returned by `execute_script` resolves to the resolved value of
that promise. Otherwise the `execute_script` promise resolves to the return
value of `fn`.
Note that `fn` is evaluated on the remote context (`executor.html` in the
example above), while `args` are evaluated on the caller context
(`injector.html`) and then passed to the remote context.
## Return value of injected functions and `execute_script()`
If the return value of the injected function when executed in the remote
context is a promise, the promise returned by `execute_script` resolves to the
resolved value of that promise. Otherwise the `execute_script` promise resolves
to the return value of the function.
When the return value of an injected script is a Promise, it should be resolved
before any navigation starts on the remote context. For example, it shouldn't
be resolved after navigating out and navigating back to the page again.
It's fine to create a Promise to be resolved after navigations, if it's not the
return value of the injected function.
## Calling timing of `execute_script()`
When `RemoteContext.execute_script()` is called when the remote context is not
active (for example before it is created, before navigation to the page, or
during the page is in back-forward cache), the injected script is evaluated
after the remote context becomes active.
Multiple calls to `RemoteContext.execute_script()` will result in multiple scripts
being executed in remote context and ordering will be maintained.
## Errors from `execute_script()`
Errors from `execute_script()` will result in promise rejections, so it is
important to await the result. This can be `await ctx.execute_script(...)` for
every call but if there are multiple scripts to executed, it may be preferable
to wait on them in parallel to avoid incurring full round-trip time for each,
e.g.
```js
await Promise.all(
ctx1.execute_script(...),
ctx1.execute_script(...),
ctx2.execute_script(...),
ctx2.execute_script(...),
...
)
```
## Evaluation timing of injected functions
The script injected by `RemoteContext.execute_script()` can be evaluated any
time during the remote context is active.
For example, even before DOMContentLoaded events or even during navigation.
It's the responsibility of test-specific code/helpers to ensure evaluation
timing constraints (which can be also test-specific), if any needed.
### Ensuring evaluation timing around page load
For example, to ensure that injected functions (`mainFunction` below) are
evaluated after the first `pageshow` event, we can use pure JavaScript code
like below:
```
// executor.html
window.pageShowPromise = new Promise(resolve =>
window.addEventListener('pageshow', resolve, {once: true}));
// injector.html
const waitForPageShow = async () => {
while (!window.pageShowPromise) {
await new Promise(resolve => setTimeout(resolve, 100));
}
await window.pageShowPromise;
};
await ctx.execute(waitForPageShow);
await ctx.execute(mainFunction);
```
### Ensuring evaluation timing around navigation out/unloading
It can be important to ensure there are no injected functions nor code behind
`RemoteContext` (such as Fetch APIs accessing server-side stash) running after
navigation is initiated, for example in the case of back-forward cache testing.
To ensure this,
- Do not call the next `RemoteContext.execute()` for the remote context after
triggering the navigation, until we are sure that the remote context is not
active (e.g. after we confirm that the new page is loaded).
- Call `Executor.suspend(callback)` synchronously within the injected script.
This suspends executor-related code, and calls `callback` when it is ready
to start navigation.
The code on the injector side would be like:
```
// injector.html
await ctx.execute_script(() => {
executor.suspend(() => {
location.href = 'new-url.html';
});
});
```
## Future Work: Possible integration with `test_driver`
Currently `RemoteContext` is implemented by JavaScript and WPT-server-side
stash, and not integrated with `test_driver` nor `testharness`.
There is a proposal of `test_driver`-integrated version (see the RFCs listed
above).
The API semantics and guidelines in this document are designed to be applicable
to both the current stash-based `RemoteContext` and `test_driver`-based
version, and thus the tests using `RemoteContext` will be migrated with minimum
modifications (mostly in `/common/dispatcher/dispatcher.js` and executors), for
example in a
[draft CL](https://chromium-review.googlesource.com/c/chromium/src/+/3082215/).
# `send()`/`receive()` Message passing APIs
`dispatcher.js` (and its server-side backend `dispatcher.py`) provides a
universal queue-based message passing API.
Each queue is identified by a UUID, and accessed via the following APIs:
- `send(uuid, message)` pushes a string `message` to the queue `uuid`.
- `receive(uuid)` pops the first item from the queue `uuid`.
- `showRequestHeaders(origin, uuid)` and
`cacheableShowRequestHeaders(origin, uuid)` return URLs, that push request
headers to the queue `uuid` upon fetching.
It works cross-origin, and even access different browser context groups.
Messages are queued, this means one doesn't need to wait for the receiver to
listen, before sending the first message
(but still need to wait for the resolution of the promise returned by `send()`
to ensure the order between `send()`s).
## Executors
Similar to `RemoteContext.execute_script()`, `send()`/`receive()` can be used
for sending arbitrary javascript to be evaluated in another page or worker.
- `executor.html` (as a Document),
- `executor-worker.js` (as a Web Worker), and
- `executor-service-worker.js` (as a Service Worker)
are examples of executors.
Note that these executors are NOT compatible with
`RemoteContext.execute_script()`.
## Future Work
`send()`, `receive()` and the executors below are kept for COEP/COOP tests.
For remote script execution, new tests should use
`RemoteContext.execute_script()` instead.
For message passing,
[WPT RFC 90](https://github.com/web-platform-tests/rfcs/pull/90) is still under
discussion.
+256
View File
@@ -0,0 +1,256 @@
// Define a universal message passing API. It works cross-origin and across
// browsing context groups.
const dispatcher_path = "/common/dispatcher/dispatcher.py";
const dispatcher_url = new URL(dispatcher_path, location.href).href;
// Return a promise, limiting the number of concurrent accesses to a shared
// resources to |max_concurrent_access|.
const concurrencyLimiter = (max_concurrency) => {
let pending = 0;
let waiting = [];
return async (task) => {
pending++;
if (pending > max_concurrency)
await new Promise(resolve => waiting.push(resolve));
let result = await task();
pending--;
waiting.shift()?.();
return result;
};
}
// Wait for a random amount of time in the range [10ms,100ms].
const randomDelay = () => {
return new Promise(resolve => setTimeout(resolve, 10 + 90*Math.random()));
}
// Sending too many requests in parallel causes congestion. Limiting it improves
// throughput.
//
// Note: The following table has been determined on the test:
// ../cache-storage.tentative.https.html
// using Chrome with a 64 core CPU / 64GB ram, in release mode:
// ┌───────────┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬────┐
// │concurrency│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 10│ 15│ 20│ 30│ 50│ 100│
// ├───────────┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼────┤
// │time (s) │ 54│ 38│ 31│ 29│ 26│ 24│ 22│ 22│ 22│ 22│ 34│ 36 │
// └───────────┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴────┘
const limiter = concurrencyLimiter(6);
// While requests to different remote contexts can go in parallel, we need to
// ensure that requests to each remote context are done in order. This maps a
// uuid to a queue of requests to send. A queue is processed until it is empty
// and then is deleted from the map.
const sendQueues = new Map();
// Sends a single item (with rate-limiting) and calls the associated resolver
// when it is successfully sent.
const sendItem = async function (uuid, resolver, message) {
await limiter(async () => {
// Requests might be dropped. Retry until getting a confirmation it has been
// processed.
while(1) {
try {
let response = await fetch(dispatcher_url + `?uuid=${uuid}`, {
method: 'POST',
body: message
})
if (await response.text() == "done") {
resolver();
return;
}
} catch (fetch_error) {}
await randomDelay();
};
});
}
// While the queue is non-empty, send the next item. This is async and new items
// may be added to the queue while others are being sent.
const processQueue = async function (uuid, queue) {
while (queue.length) {
const [resolver, message] = queue.shift();
await sendItem(uuid, resolver, message);
}
// The queue is empty, delete it.
sendQueues.delete(uuid);
}
const send = async function (uuid, message) {
const itemSentPromise = new Promise((resolve) => {
const item = [resolve, message];
if (sendQueues.has(uuid)) {
// There is already a queue for `uuid`, just add to it and it will be processed.
sendQueues.get(uuid).push(item);
} else {
// There is no queue for `uuid`, create it and start processing.
const queue = [item];
sendQueues.set(uuid, queue);
processQueue(uuid, queue);
}
});
// Wait until the item has been successfully sent.
await itemSentPromise;
}
const receive = async function (uuid) {
while(1) {
let data = "not ready";
try {
data = await limiter(async () => {
let response = await fetch(dispatcher_url + `?uuid=${uuid}`);
return await response.text();
});
} catch (fetch_error) {}
if (data == "not ready") {
await randomDelay();
continue;
}
return data;
}
}
// Returns an URL. When called, the server sends toward the `uuid` queue the
// request headers. Useful for determining if something was requested with
// Cookies.
const showRequestHeaders = function(origin, uuid) {
return origin + dispatcher_path + `?uuid=${uuid}&show-headers`;
}
// Same as above, except for the response is cacheable.
const cacheableShowRequestHeaders = function(origin, uuid) {
return origin + dispatcher_path + `?uuid=${uuid}&cacheable&show-headers`;
}
// This script requires
// - `/common/utils.js` for `token()`.
// Returns the URL of a document that can be used as a `RemoteContext`.
//
// `uuid` should be a UUID uniquely identifying the given remote context.
// `options` has the following shape:
//
// {
// host: (optional) Sets the returned URL's `host` property. Useful for
// cross-origin executors.
// protocol: (optional) Sets the returned URL's `protocol` property.
// }
function remoteExecutorUrl(uuid, options) {
const url = new URL("/common/dispatcher/remote-executor.html", location);
url.searchParams.set("uuid", uuid);
if (options?.host) {
url.host = options.host;
}
if (options?.protocol) {
url.protocol = options.protocol;
}
return url;
}
// Represents a remote executor. For more detailed explanation see `README.md`.
class RemoteContext {
// `uuid` is a UUID string that identifies the remote context and should
// match with the `uuid` parameter of the URL of the remote context.
constructor(uuid) {
this.context_id = uuid;
}
// Evaluates the script `expr` on the executor.
// - If `expr` is evaluated to a Promise that is resolved with a value:
// `execute_script()` returns a Promise resolved with the value.
// - If `expr` is evaluated to a non-Promise value:
// `execute_script()` returns a Promise resolved with the value.
// - If `expr` throws an error or is evaluated to a Promise that is rejected:
// `execute_script()` returns a rejected Promise with the error's
// `message`.
// Note that currently the type of error (e.g. DOMException) is not
// preserved, except for `TypeError`.
// The values should be able to be serialized by JSON.stringify().
async execute_script(fn, args) {
const receiver = token();
await this.send({receiver: receiver, fn: fn.toString(), args: args});
const response = JSON.parse(await receive(receiver));
if (response.status === 'success') {
return response.value;
}
// exception
if (response.name === 'TypeError') {
throw new TypeError(response.value);
}
throw new Error(response.value);
}
async send(msg) {
return await send(this.context_id, JSON.stringify(msg));
}
};
class Executor {
constructor(uuid) {
this.uuid = uuid;
// If `suspend_callback` is not `null`, the executor should be suspended
// when there are no ongoing tasks.
this.suspend_callback = null;
this.execute();
}
// Wait until there are no ongoing tasks nor fetch requests for polling
// tasks, and then suspend the executor and call `callback()`.
// Navigation from the executor page should be triggered inside `callback()`,
// to avoid conflict with in-flight fetch requests.
suspend(callback) {
this.suspend_callback = callback;
}
resume() {
}
async execute() {
while(true) {
if (this.suspend_callback !== null) {
this.suspend_callback();
this.suspend_callback = null;
// Wait for `resume()` to be called.
await new Promise(resolve => this.resume = resolve);
// Workaround for https://crbug.com/1244230.
// Without this workaround, the executor is resumed and the fetch
// request to poll the next task is initiated synchronously from
// pageshow event after the page restored from BFCache, and the fetch
// request promise is never resolved (and thus the test results in
// timeout) due to https://crbug.com/1244230. The root cause is not yet
// known, but setTimeout() with 0ms causes the resume triggered on
// another task and seems to resolve the issue.
await new Promise(resolve => setTimeout(resolve, 0));
continue;
}
const task = JSON.parse(await receive(this.uuid));
let response;
try {
const value = await eval(task.fn).apply(null, task.args);
response = JSON.stringify({
status: 'success',
value: value
});
} catch(e) {
response = JSON.stringify({
status: 'exception',
name: e.name,
value: e.message
});
}
await send(task.receiver, response);
}
}
}
@@ -0,0 +1,24 @@
importScripts('./dispatcher.js');
const params = new URLSearchParams(location.search);
const uuid = params.get('uuid');
// The fetch handler must be registered before parsing the main script response.
// So do it here, for future use.
fetchHandler = () => {}
addEventListener('fetch', e => {
fetchHandler(e);
});
// Force ServiceWorker to immediately activate itself.
addEventListener('install', event => {
skipWaiting();
});
let executeOrders = async function() {
while(true) {
let task = await receive(uuid);
eval(`(async () => {${task}})()`);
}
};
executeOrders();
+12
View File
@@ -0,0 +1,12 @@
importScripts('./dispatcher.js');
const params = new URLSearchParams(location.search);
const uuid = params.get('uuid');
let executeOrders = async function() {
while(true) {
let task = await receive(uuid);
eval(`(async () => {${task}})()`);
}
};
executeOrders();
+15
View File
@@ -0,0 +1,15 @@
<script src="./dispatcher.js"></script>
<script>
const params = new URLSearchParams(window.location.search);
const uuid = params.get('uuid');
let executeOrders = async function() {
while(true) {
let task = await receive(uuid);
eval(`(async () => {${task}})()`);
}
};
executeOrders();
</script>
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<body>
</body>
<script src="./dispatcher.js"></script>
<script>
const params = new URLSearchParams(window.location.search);
const uuid = params.get('uuid');
const executor = new Executor(uuid); // `execute()` is called in constructor.
</script>
</html>
+52
View File
@@ -0,0 +1,52 @@
/**
* Does a best-effort attempt at invoking garbage collection. Attempts to use
* the standardized `TestUtils.gc()` function, but falls back to other
* environment-specific nonstandard functions, with a final result of just
* creating a lot of garbage (in which case you will get a console warning).
*
* This should generally only be used to attempt to trigger bugs and crashes
* inside tests, i.e. cases where if garbage collection happened, then this
* should not trigger some misbehavior. You cannot rely on garbage collection
* successfully trigger, or that any particular unreachable object will be
* collected.
*
* @returns {Promise<undefined>} A promise you should await to ensure garbage
* collection has had a chance to complete.
*/
self.garbageCollect = async () => {
// https://testutils.spec.whatwg.org/#the-testutils-namespace
if (self.TestUtils?.gc) {
return TestUtils.gc();
}
// Use --expose_gc for V8 (and Node.js)
// to pass this flag at chrome launch use: --js-flags="--expose-gc"
// Exposed in SpiderMonkey shell as well
if (self.gc) {
return self.gc();
}
// Present in some WebKit development environments
if (self.GCController) {
return GCController.collect();
}
console.warn(
'Tests are running without the ability to do manual garbage collection. ' +
'They will still work, but coverage will be suboptimal.');
for (var i = 0; i < 1000; i++) {
gcRec(10);
}
function gcRec(n) {
if (n < 1) {
return {};
}
let temp = { i: "ab" + i + i / 100000 };
temp += "foo";
gcRec(n - 1);
}
};
+2 -2
View File
@@ -47,9 +47,9 @@ function getMediaContentType(url) {
var extension = new URL(url, location).pathname.split(".").pop();
var map = {
"mp4": "video/mp4",
"ogv": "video/ogg",
"ogv": "application/ogg",
"mp3": "audio/mp3",
"oga": "audio/ogg",
"oga": "application/ogg",
};
return map[extension];
}
+41 -35
View File
@@ -1,19 +1,48 @@
"use strict";
// For now this only has per-Window tests, but we could expand it to also test per-Document
// This is for testing whether an object (e.g., a global property) is associated with Window, or
// with Document. Recall that Window and Document are 1:1 except when doing a same-origin navigation
// away from the initial about:blank. In that case the Window object gets reused for the new
// Document.
//
// So:
// - If something is per-Window, then it should maintain its identity across an about:blank
// navigation.
// - If something is per-Document, then it should be recreated across an about:blank navigation.
/**
* Run tests for window[propertyName] after discarding the browsing context, navigating, etc.
* @param {string} propertyName
*/
window.testIsPerWindow = propertyName => {
test(t => {
runTests(propertyName, assert_equals, "must not");
};
window.testIsPerDocument = propertyName => {
runTests(propertyName, assert_not_equals, "must");
};
function runTests(propertyName, equalityOrInequalityAsserter, mustOrMustNotReplace) {
async_test(t => {
const iframe = document.createElement("iframe");
document.body.appendChild(iframe);
const frame = iframe.contentWindow;
const before = frame[propertyName];
assert_true(before !== undefined && before !== null, `window.${propertyName} must be implemented`);
assert_implements(before, `window.${propertyName} must be implemented`);
iframe.onload = t.step_func_done(() => {
const after = frame[propertyName];
equalityOrInequalityAsserter(after, before);
});
iframe.src = "/common/blank.html";
}, `Navigating from the initial about:blank ${mustOrMustNotReplace} replace window.${propertyName}`);
// Per spec, discarding a browsing context should not change any of the global objects.
test(() => {
const iframe = document.createElement("iframe");
document.body.appendChild(iframe);
const frame = iframe.contentWindow;
const before = frame[propertyName];
assert_implements(before, `window.${propertyName} must be implemented`);
iframe.remove();
@@ -21,38 +50,15 @@ window.testIsPerWindow = propertyName => {
assert_equals(after, before, `window.${propertyName} should not change after iframe.remove()`);
}, `Discarding the browsing context must not change window.${propertyName}`);
async_test(t => {
const iframe = document.createElement("iframe");
document.body.appendChild(iframe);
const frame = iframe.contentWindow;
const before = frame[propertyName];
assert_true(before !== undefined && before !== null, `window.${propertyName} must be implemented`);
// Note: cannot use step_func_done for this because it might be called twice, per the below comment.
iframe.onload = t.step_func(() => {
if (frame.location.href === "about:blank") {
// Browsers are not reliable on whether about:blank fires the load event; see
// https://github.com/whatwg/html/issues/490
return;
}
const after = frame[propertyName];
assert_equals(after, before);
t.done();
});
iframe.src = "/common/blank.html";
}, `Navigating from the initial about:blank must not replace window.${propertyName}`);
// Per spec, document.open() should not change any of the Window state.
// Per spec, document.open() should not change any of the global objects. In historical versions
// of the spec, it did, so we test here.
async_test(t => {
const iframe = document.createElement("iframe");
iframe.onload = t.step_func_done(() => {
const frame = iframe.contentWindow;
const before = frame[propertyName];
assert_true(before !== undefined && before !== null, `window.${propertyName} must be implemented`);
assert_implements(before, `window.${propertyName} must be implemented`);
frame.document.open();
@@ -64,5 +70,5 @@ window.testIsPerWindow = propertyName => {
iframe.src = "/common/blank.html";
document.body.appendChild(iframe);
}, `document.open() must replace window.${propertyName}`);
};
}, `document.open() must not replace window.${propertyName}`);
}
+3
View File
@@ -0,0 +1,3 @@
function FindProxyForURL(url, host) {
return "PROXY {{host}}:{{ports[http][0]}}"
}
+19
View File
@@ -18,3 +18,22 @@ function takeScreenshotDelayed(timeout) {
takeScreenshot();
}, timeout);
}
/**
* Ensure that a precondition is met before waiting for a screenshot.
* @param {bool} condition - Fail the test if this evaluates to false
* @param {string} msg - Error message to write to the screenshot
*/
function failIfNot(condition, msg) {
const fail = () => {
(document.body || document.documentElement).textContent = `Precondition Failed: ${msg}`;
takeScreenshot();
};
if (!condition) {
if (document.readyState == "interactive") {
fail();
} else {
document.addEventListener("DOMContentLoaded", fail, false);
}
}
}
+3 -3
View File
@@ -6,14 +6,14 @@ const createBuffer = (() => {
} catch(e) {
sabConstructor = null;
}
return (type, length) => {
return (type, length, opts) => {
if (type === "ArrayBuffer") {
return new ArrayBuffer(length);
return new ArrayBuffer(length, opts);
} else if (type === "SharedArrayBuffer") {
if (sabConstructor && sabConstructor.name !== "SharedArrayBuffer") {
throw new Error("WebAssembly.Memory does not support shared:true");
}
return new sabConstructor(length);
return new sabConstructor(length, opts);
} else {
throw new Error("type has to be ArrayBuffer or SharedArrayBuffer");
}
@@ -485,9 +485,13 @@ function dedicatedWorkerUrlThatFetches(url) {
.catch((e) => postMessage(e.message));`;
}
function workerUrlThatImports(url) {
function workerUrlThatImports(url, additionalAttributes) {
let csp = "";
if (additionalAttributes && additionalAttributes.contentSecurityPolicy) {
csp=`&contentSecurityPolicy=${additionalAttributes.contentSecurityPolicy}`;
}
return `/common/security-features/subresource/static-import.py` +
`?import_url=${encodeURIComponent(url)}`;
`?import_url=${encodeURIComponent(url)}${csp}`;
}
function workerDataUrlThatImports(url) {
@@ -630,6 +634,24 @@ function requestViaScript(url, additionalAttributes) {
.then(event => wrapResult(event.data));
}
/**
* Creates a new script element that performs a dynamic import to `url`, and
* appends the script element to {@code document.body}.
* @param {string} url The src URL.
* @return {Promise} The promise for success/error events.
*/
function requestViaDynamicImport(url, additionalAttributes) {
const scriptUrl = `data:text/javascript,import("${url}");`;
const script = createElement(
"script",
Object.assign({"src": scriptUrl}, additionalAttributes),
document.body,
false);
return bindEvents2(window, "message", script, "error", window, "error")
.then(event => wrapResult(event.data));
}
/**
* Creates a new form element, sets attributes, appends it to
* {@code document.body} and submits the form.
@@ -866,6 +888,10 @@ const subresourceMap = {
path: "/common/security-features/subresource/script.py",
invoker: requestViaScript,
},
"script-tag-dynamic-import": {
path: "/common/security-features/subresource/script.py",
invoker: requestViaDynamicImport,
},
"video-tag": {
path: "/common/security-features/subresource/video.py",
invoker: requestViaVideo,
@@ -885,8 +911,8 @@ const subresourceMap = {
},
"worker-import": {
path: "/common/security-features/subresource/worker.py",
invoker: url =>
requestViaDedicatedWorker(workerUrlThatImports(url), {type: "module"}),
invoker: (url, additionalAttributes) =>
requestViaDedicatedWorker(workerUrlThatImports(url, additionalAttributes), {type: "module"}),
},
"worker-import-data": {
path: "/common/security-features/subresource/worker.py",
@@ -903,8 +929,8 @@ const subresourceMap = {
},
"sharedworker-import": {
path: "/common/security-features/subresource/shared-worker.py",
invoker: url =>
requestViaSharedWorker(workerUrlThatImports(url), {type: "module"}),
invoker: (url, additionalAttributes) =>
requestViaSharedWorker(workerUrlThatImports(url, additionalAttributes), {type: "module"}),
},
"sharedworker-import-data": {
path: "/common/security-features/subresource/shared-worker.py",
@@ -1087,6 +1113,10 @@ function invokeRequest(subresource, sourceContextList) {
additionalAttributes[policyDelivery.key] = policyDelivery.value;
} else if (policyDelivery.deliveryType === "rel-noref") {
additionalAttributes["rel"] = "noreferrer";
} else if (policyDelivery.deliveryType === "http-rp") {
additionalAttributes[policyDelivery.key] = policyDelivery.value;
} else if (policyDelivery.deliveryType === "meta") {
additionalAttributes[policyDelivery.key] = policyDelivery.value;
}
}
@@ -106,6 +106,7 @@
"object-tag",
"picture-tag",
"script-tag",
"script-tag-dynamic-import",
"sharedworker-classic",
"sharedworker-import",
"sharedworker-import-data",
@@ -327,26 +328,6 @@
],
"subresourcePolicyDeliveries": []
},
"worker-classic-inherit": {
// This is applicable to upgrade-insecure-requests and mixed-content tests.
// Use "worker-classic" for referrer-policy.
"description": "dedicated workers should inherit its parent's policy.",
"sourceContextList": [
{
"sourceContextType": "top",
"policyDeliveries": [
"policy"
]
},
{
"sourceContextType": "worker-classic",
"policyDeliveries": [
"anotherPolicy"
]
}
],
"subresourcePolicyDeliveries": []
},
"worker-classic-data": {
"description": "data: dedicated workers should inherit its parent's policy.",
"sourceContextList": [
@@ -365,7 +346,6 @@
},
"worker-module": {
// This is applicable to referrer-policy tests.
// Use "worker-module-inherit" for CSP (mixed-content, etc.).
"description": "dedicated workers shouldn't inherit its parent's policy.",
"sourceContextList": [
{
@@ -383,26 +363,6 @@
],
"subresourcePolicyDeliveries": []
},
"worker-module-inherit": {
// This is applicable to upgrade-insecure-requests and mixed-content tests.
// Use "worker-module" for referrer-policy.
"description": "dedicated workers should inherit its parent's policy.",
"sourceContextList": [
{
"sourceContextType": "top",
"policyDeliveries": [
"policy"
]
},
{
"sourceContextType": "worker-module",
"policyDeliveries": [
"anotherPolicy"
]
}
],
"subresourcePolicyDeliveries": []
},
"worker-module-data": {
"description": "data: dedicated workers should inherit its parent's policy.",
"sourceContextList": [
@@ -505,10 +465,8 @@
"iframe",
"iframe-blank-inherit",
"worker-classic",
"worker-classic-inherit",
"worker-classic-data",
"worker-module",
"worker-module-inherit",
"worker-module-data",
"sharedworker-classic",
"sharedworker-classic-data",
@@ -550,6 +508,7 @@
"object-tag",
"picture-tag",
"script-tag",
"script-tag-dynamic-import",
"sharedworker-classic",
"sharedworker-import",
"sharedworker-import-data",
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* Runs tests for <http://heycam.github.io/webidl/#es-stringifier>.
* Runs tests for <https://webidl.spec.whatwg.org/#es-stringifier>.
* @param {Object} aObject - object to test
* @param {string} aAttribute - IDL attribute name that is annotated with `stringifier`
* @param {boolean} aIsUnforgeable - whether the IDL attribute is `[LegacyUnforgeable]`
@@ -1,73 +0,0 @@
<!DOCTYPE html>
<title>Default passive document level touchmove event listener test</title>
<link rel="help" href="https://github.com/WICG/interventions/issues/35">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<body onload=runTest()>
<div id="touchDiv">
</div>
</body>
<style>
#touchDiv {
width: 100px;
height: 100px;
}
</style>
<script>
var touch_div = document.getElementById("touchDiv");
var cancelable = true;
var touch_move_arrived = false;
document.addEventListener("touchmove", function (event) {
cancelable = event.cancelable;
touch_move_arrived = true;
event.preventDefault();
});
function waitFor(condition) {
const MAX_FRAME = 500;
return new Promise((resolve, reject) => {
function tick(frames) {
// We requestAnimationFrame either for 500 frames or until condition is
// met.
if (frames >= MAX_FRAME)
reject("Condition did not become true after 500 frames");
else if (condition())
resolve();
else
requestAnimationFrame(tick.bind(this, frames + 1));
}
tick(0);
});
}
function waitForCompositorCommit() {
return new Promise((resolve) => {
// rAF twice.
window.requestAnimationFrame(() => {
window.requestAnimationFrame(resolve);
});
});
}
function injectInput() {
new test_driver.Actions()
.addPointer("touch_pointer", "touch")
.pointerMove(0, 0, {origin: touch_div})
.pointerDown()
.pointerMove(30, 30)
.pointerUp()
.send();
}
function runTest() {
promise_test (async () => {
await waitForCompositorCommit();
injectInput();
await waitFor(()=> { return touch_move_arrived; });
assert_false(cancelable);
}, "Touchmove events are non-cancelable since the event listener is treated as passive.");
}
</script>
@@ -1,51 +0,0 @@
<!DOCTYPE html>
<title>Default passive document level wheel event listener manual test</title>
<link rel="help" href="https://github.com/WICG/interventions/issues/64">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<body onload=runTest()>
<div>This is a manual test since there is no way to synthesize wheel events.
Scroll by wheel in the middle of the page to run the test.</div>
</body>
<script>
var cancelable = true;
var wheel_arrived = false;
document.addEventListener("wheel", function (event) {
cancelable = event.cancelable;
wheel_arrived = true;
event.preventDefault();
});
function waitFor(condition) {
const MAX_FRAME = 200;
return new Promise((resolve, reject) => {
function tick(frames) {
// We requestAnimationFrame either for 200 frames or until condition is
// met.
if (frames >= MAX_FRAME)
reject("Condition did not become true after 200 frames");
else if (condition())
resolve();
else
requestAnimationFrame(tick.bind(this, frames + 1));
}
tick(0);
});
}
function runTest() {
promise_test (async () => {
const pos_x = Math.floor(window.innerWidth / 2);
const pos_y = Math.floor(window.innerHeight / 2);
const delta_x = 0;
const delta_y = 100;
await new test_driver.Actions()
.scroll(pos_x, pos_y, delta_x, delta_y).send();
await waitFor(()=> { return wheel_arrived; });
assert_false(cancelable);
}, "Wheel events are non-cancelable since the event listener is treated as passive.");
}
</script>
-21
View File
@@ -1,21 +0,0 @@
<!doctype html>
<meta charset=gb18030> <!-- if the server overrides this, it is stupid, as this is a testsuite -->
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
function encode(input, output, desc) {
test(function() {
var a = document.createElement("a") // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input
assert_equals(a.search.substr(1), output) // remove leading "?"
}, "gb18030 encoder: " + desc)
}
encode("s", "s", "very basic")
encode("\u20AC", "%A2%E3", "Euro")
encode("\u4E02", "%81@", "character")
encode("\uE4C6", "%A1@", "PUA")
encode("\uE4C5", "%FE%FE", "PUA #2")
encode("\ud83d\udca9", "%949%DA3", "poo")
</script>
-21
View File
@@ -1,21 +0,0 @@
<!doctype html>
<meta charset=gbk> <!-- if the server overrides this, it is stupid, as this is a testsuite -->
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
function encode(input, output, desc) {
test(function() {
var a = document.createElement("a") // <a> uses document encoding for URL's query
a.href = "https://example.com/?" + input
assert_equals(a.search.substr(1), output) // remove leading "?"
}, "gbk encoder: " + desc)
}
encode("s", "s", "very basic")
encode("\u20AC", "%80", "Euro")
encode("\u4E02", "%81@", "character")
encode("\uE4C6", "%A1@", "PUA")
encode("\uE4C5", "%FE%FE", "PUA #2")
encode("\ud83d\udca9", "%26%23128169%3B", "poo")
</script>
@@ -1,55 +0,0 @@
<!doctype html>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=resources/ranges.js></script>
<script>
const decode = (input, output, desc) => {
test(function() {
for (encoding of ["gb18030", "gbk"])
assert_equals(new TextDecoder(encoding).decode(new Uint8Array(input)), output)
}, "gb18030 decoder: " + desc)
}
decode([115], "s", "ASCII");
decode([0x80], "\u20AC", "euro");
decode([0xFF], "\uFFFD", "initial byte out of accepted ranges");
decode([0x81], "\uFFFD", "end of queue, gb18030 first not 0");
decode([0x81, 0x28], "\ufffd(", "two bytes 0x81 0x28");
decode([0x81, 0x40], "\u4E02", "two bytes 0x81 0x40");
decode([0x81, 0x7E], "\u4E8A", "two bytes 0x81 0x7e");
decode([0x81, 0x7F], "\ufffd\u007f", "two bytes 0x81 0x7f");
decode([0x81, 0x80], "\u4E90", "two bytes 0x81 0x80");
decode([0x81, 0xFE], "\u4FA2", "two bytes 0x81 0xFE");
decode([0x81, 0xFF], "\ufffd", "two bytes 0x81 0xFF");
decode([0xFE, 0x40], "\uFA0C", "two bytes 0xFE 0x40");
decode([0xFE, 0xFE], "\uE4C5", "two bytes 0xFE 0xFE");
decode([0xFE, 0xFF], "\ufffd", "two bytes 0xFE 0xFF");
decode([0x81, 0x30], "\ufffd", "two bytes 0x81 0x30");
decode([0x81, 0x30, 0xFE], "\ufffd", "three bytes 0x81 0x30 0xFE");
decode([0x81, 0x30, 0xFF], "\ufffd0\ufffd", "three bytes 0x81 0x30 0xFF");
decode([0x81, 0x30, 0xFE, 0x29], "\ufffd0\ufffd)", "four bytes 0x81 0x30 0xFE 0x29");
decode([0xFE, 0x39, 0xFE, 0x39], "\ufffd", "four bytes 0xFE 0x39 0xFE 0x39");
decode([0x81, 0x35, 0xF4, 0x36], "\u1E3E", "pointer 7458");
decode([0x81, 0x35, 0xF4, 0x37], "\ue7c7", "pointer 7457");
decode([0x81, 0x35, 0xF4, 0x38], "\u1E40", "pointer 7459");
decode([0x84, 0x31, 0xA4, 0x39], "\uffff", "pointer 39419");
decode([0x84, 0x31, 0xA5, 0x30], "\ufffd", "pointer 39420");
decode([0x8F, 0x39, 0xFE, 0x39], "\ufffd", "pointer 189999");
decode([0x90, 0x30, 0x81, 0x30], "\u{10000}", "pointer 189000");
decode([0xE3, 0x32, 0x9A, 0x35], "\u{10FFFF}", "pointer 1237575");
decode([0xE3, 0x32, 0x9A, 0x36], "\ufffd", "pointer 1237576");
decode([0x83, 0x36, 0xC8, 0x30], "\uE7C8", "legacy ICU special case 1");
decode([0xA1, 0xAD], "\u2026", "legacy ICU special case 2");
decode([0xA1, 0xAB], "\uFF5E", "legacy ICU special case 3");
let i = 0;
for (const range of ranges) {
const pointer = range[0];
decode([
Math.floor(pointer / 12600) + 0x81,
Math.floor((pointer % 12600) / 1260) + 0x30,
Math.floor((pointer % 1260) / 10) + 0x81,
pointer % 10 + 0x30
], range[1], "range " + i++);
}
</script>
@@ -1,33 +0,0 @@
<!doctype html>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
const gbkPointers = [
6432, 7533, 7536, 7672, 7673, 7674, 7675, 7676, 7677, 7678, 7679, 7680, 7681, 7682, 7683, 7684,
23766, 23770, 23771, 23772, 23773, 23774, 23776, 23777, 23778, 23779, 23780, 23781, 23782, 23784, 23785, 23786,
23787, 23790, 23791, 23792, 23793, 23796, 23797, 23798, 23799, 23800, 23801, 23802, 23803, 23805, 23806, 23807,
23808, 23809, 23810, 23811, 23813, 23814, 23815, 23816, 23817, 23818, 23819, 23820, 23821, 23822, 23823, 23824,
23825, 23826, 23827, 23828, 23831, 23832, 23833, 23834, 23835, 23836, 23837, 23838, 23839, 23840, 23841, 23842,
23843, 23844
];
const codePoints = [
0x20ac, 0x1e3f, 0x01f9, 0x303e, 0x2ff0, 0x2ff1, 0x2ff2, 0x2ff3, 0x2ff4, 0x2ff5, 0x2ff6, 0x2ff7, 0x2ff8, 0x2ff9, 0x2ffa, 0x2ffb,
0x2e81, 0x2e84, 0x3473, 0x3447, 0x2e88, 0x2e8b, 0x359e, 0x361a, 0x360e, 0x2e8c, 0x2e97, 0x396e, 0x3918, 0x39cf, 0x39df, 0x3a73,
0x39d0, 0x3b4e, 0x3c6e, 0x3ce0, 0x2ea7, 0x2eaa, 0x4056, 0x415f, 0x2eae, 0x4337, 0x2eb3, 0x2eb6, 0x2eb7, 0x43b1, 0x43ac, 0x2ebb,
0x43dd, 0x44d6, 0x4661, 0x464c, 0x4723, 0x4729, 0x477c, 0x478d, 0x2eca, 0x4947, 0x497a, 0x497d, 0x4982, 0x4983, 0x4985, 0x4986,
0x499f, 0x499b, 0x49b7, 0x49b6, 0x4ca3, 0x4c9f, 0x4ca0, 0x4ca1, 0x4c77, 0x4ca2, 0x4d13, 0x4d14, 0x4d15, 0x4d16, 0x4d17, 0x4d18,
0x4d19, 0x4dae
];
for (let i = 0; i < gbkPointers.length; i++) {
const pointer = gbkPointers[i];
test(function() {
const lead = pointer / 190 + 0x81;
const trail = pointer % 190;
const offset = trail < 0x3F ? 0x40 : 0x41;
const encoded = [lead, trail + offset];
const decoded = new TextDecoder("GBK").decode(new Uint8Array(encoded)).charCodeAt(0);
assert_equals(decoded, codePoints[i]);
}, "gbk pointer: " + pointer)
}
</script>
-113
View File
@@ -1,113 +0,0 @@
<!doctype html>
<meta name=timeout content=long>
<meta name="variant" content="?XMLHttpRequest">
<meta name="variant" content="?TextDecoder">
<meta name="variant" content="?document">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=resources/encodings.js></script>
<div id=log></div>
<script>
var singleByteEncodings = encodings_table.filter(function(group) {
return group.heading === "Legacy single-byte encodings";
})[0].encodings,
// https://encoding.spec.whatwg.org/indexes.json
singleByteIndexes = {
"IBM866":[1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488,9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575,9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,1025,1105,1028,1108,1031,1111,1038,1118,176,8729,183,8730,8470,164,9632,160],
"ISO-8859-2":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,728,321,164,317,346,167,168,352,350,356,377,173,381,379,176,261,731,322,180,318,347,711,184,353,351,357,378,733,382,380,340,193,194,258,196,313,262,199,268,201,280,203,282,205,206,270,272,323,327,211,212,336,214,215,344,366,218,368,220,221,354,223,341,225,226,259,228,314,263,231,269,233,281,235,283,237,238,271,273,324,328,243,244,337,246,247,345,367,250,369,252,253,355,729],
"ISO-8859-3":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,294,728,163,164,null,292,167,168,304,350,286,308,173,null,379,176,295,178,179,180,181,293,183,184,305,351,287,309,189,null,380,192,193,194,null,196,266,264,199,200,201,202,203,204,205,206,207,null,209,210,211,212,288,214,215,284,217,218,219,220,364,348,223,224,225,226,null,228,267,265,231,232,233,234,235,236,237,238,239,null,241,242,243,244,289,246,247,285,249,250,251,252,365,349,729],
"ISO-8859-4":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,312,342,164,296,315,167,168,352,274,290,358,173,381,175,176,261,731,343,180,297,316,711,184,353,275,291,359,330,382,331,256,193,194,195,196,197,198,302,268,201,280,203,278,205,206,298,272,325,332,310,212,213,214,215,216,370,218,219,220,360,362,223,257,225,226,227,228,229,230,303,269,233,281,235,279,237,238,299,273,326,333,311,244,245,246,247,248,371,250,251,252,361,363,729],
"ISO-8859-5":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,173,1038,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,8470,1105,1106,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,167,1118,1119],
"ISO-8859-6":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,null,null,null,164,null,null,null,null,null,null,null,1548,173,null,null,null,null,null,null,null,null,null,null,null,null,null,1563,null,null,null,1567,null,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,1591,1592,1593,1594,null,null,null,null,null,1600,1601,1602,1603,1604,1605,1606,1607,1608,1609,1610,1611,1612,1613,1614,1615,1616,1617,1618,null,null,null,null,null,null,null,null,null,null,null,null,null],
"ISO-8859-7":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,8216,8217,163,8364,8367,166,167,168,169,890,171,172,173,null,8213,176,177,178,179,900,901,902,183,904,905,906,187,908,189,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,null,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,null],
"ISO-8859-8":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,null,162,163,164,165,166,167,168,169,215,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,247,187,188,189,190,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,8215,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,null,null,8206,8207,null],
"ISO-8859-10":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,274,290,298,296,310,167,315,272,352,358,381,173,362,330,176,261,275,291,299,297,311,183,316,273,353,359,382,8213,363,331,256,193,194,195,196,197,198,302,268,201,280,203,278,205,206,207,208,325,332,211,212,213,214,360,216,370,218,219,220,221,222,223,257,225,226,227,228,229,230,303,269,233,281,235,279,237,238,239,240,326,333,243,244,245,246,361,248,371,250,251,252,253,254,312],
"ISO-8859-13":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,8221,162,163,164,8222,166,167,216,169,342,171,172,173,174,198,176,177,178,179,8220,181,182,183,248,185,343,187,188,189,190,230,260,302,256,262,196,197,280,274,268,201,377,278,290,310,298,315,352,323,325,211,332,213,214,215,370,321,346,362,220,379,381,223,261,303,257,263,228,229,281,275,269,233,378,279,291,311,299,316,353,324,326,243,333,245,246,247,371,322,347,363,252,380,382,8217],
"ISO-8859-14":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,7682,7683,163,266,267,7690,167,7808,169,7810,7691,7922,173,174,376,7710,7711,288,289,7744,7745,182,7766,7809,7767,7811,7776,7923,7812,7813,7777,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,372,209,210,211,212,213,214,7786,216,217,218,219,220,221,374,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,373,241,242,243,244,245,246,7787,248,249,250,251,252,253,375,255],
"ISO-8859-15":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,8364,165,352,167,353,169,170,171,172,173,174,175,176,177,178,179,381,181,182,183,382,185,186,187,338,339,376,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255],
"ISO-8859-16":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,261,321,8364,8222,352,167,353,169,536,171,377,173,378,379,176,177,268,322,381,8221,182,183,382,269,537,187,338,339,376,380,192,193,194,258,196,262,198,199,200,201,202,203,204,205,206,207,272,323,210,211,212,336,214,346,368,217,218,219,220,280,538,223,224,225,226,259,228,263,230,231,232,233,234,235,236,237,238,239,273,324,242,243,244,337,246,347,369,249,250,251,252,281,539,255],
"KOI8-R":[9472,9474,9484,9488,9492,9496,9500,9508,9516,9524,9532,9600,9604,9608,9612,9616,9617,9618,9619,8992,9632,8729,8730,8776,8804,8805,160,8993,176,178,183,247,9552,9553,9554,1105,9555,9556,9557,9558,9559,9560,9561,9562,9563,9564,9565,9566,9567,9568,9569,1025,9570,9571,9572,9573,9574,9575,9576,9577,9578,9579,9580,169,1102,1072,1073,1094,1076,1077,1092,1075,1093,1080,1081,1082,1083,1084,1085,1086,1087,1103,1088,1089,1090,1091,1078,1074,1100,1099,1079,1096,1101,1097,1095,1098,1070,1040,1041,1062,1044,1045,1060,1043,1061,1048,1049,1050,1051,1052,1053,1054,1055,1071,1056,1057,1058,1059,1046,1042,1068,1067,1047,1064,1069,1065,1063,1066],
"KOI8-U":[9472,9474,9484,9488,9492,9496,9500,9508,9516,9524,9532,9600,9604,9608,9612,9616,9617,9618,9619,8992,9632,8729,8730,8776,8804,8805,160,8993,176,178,183,247,9552,9553,9554,1105,1108,9556,1110,1111,9559,9560,9561,9562,9563,1169,1118,9566,9567,9568,9569,1025,1028,9571,1030,1031,9574,9575,9576,9577,9578,1168,1038,169,1102,1072,1073,1094,1076,1077,1092,1075,1093,1080,1081,1082,1083,1084,1085,1086,1087,1103,1088,1089,1090,1091,1078,1074,1100,1099,1079,1096,1101,1097,1095,1098,1070,1040,1041,1062,1044,1045,1060,1043,1061,1048,1049,1050,1051,1052,1053,1054,1055,1071,1056,1057,1058,1059,1046,1042,1068,1067,1047,1064,1069,1065,1063,1066],
"macintosh":[196,197,199,201,209,214,220,225,224,226,228,227,229,231,233,232,234,235,237,236,238,239,241,243,242,244,246,245,250,249,251,252,8224,176,162,163,167,8226,182,223,174,169,8482,180,168,8800,198,216,8734,177,8804,8805,165,181,8706,8721,8719,960,8747,170,186,937,230,248,191,161,172,8730,402,8776,8710,171,187,8230,160,192,195,213,338,339,8211,8212,8220,8221,8216,8217,247,9674,255,376,8260,8364,8249,8250,64257,64258,8225,183,8218,8222,8240,194,202,193,203,200,205,206,207,204,211,212,63743,210,218,219,217,305,710,732,175,728,729,730,184,733,731,711],
"windows-874":[8364,129,130,131,132,8230,134,135,136,137,138,139,140,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,152,153,154,155,156,157,158,159,160,3585,3586,3587,3588,3589,3590,3591,3592,3593,3594,3595,3596,3597,3598,3599,3600,3601,3602,3603,3604,3605,3606,3607,3608,3609,3610,3611,3612,3613,3614,3615,3616,3617,3618,3619,3620,3621,3622,3623,3624,3625,3626,3627,3628,3629,3630,3631,3632,3633,3634,3635,3636,3637,3638,3639,3640,3641,3642,null,null,null,null,3647,3648,3649,3650,3651,3652,3653,3654,3655,3656,3657,3658,3659,3660,3661,3662,3663,3664,3665,3666,3667,3668,3669,3670,3671,3672,3673,3674,3675,null,null,null,null],
"windows-1250":[8364,129,8218,131,8222,8230,8224,8225,136,8240,352,8249,346,356,381,377,144,8216,8217,8220,8221,8226,8211,8212,152,8482,353,8250,347,357,382,378,160,711,728,321,164,260,166,167,168,169,350,171,172,173,174,379,176,177,731,322,180,181,182,183,184,261,351,187,317,733,318,380,340,193,194,258,196,313,262,199,268,201,280,203,282,205,206,270,272,323,327,211,212,336,214,215,344,366,218,368,220,221,354,223,341,225,226,259,228,314,263,231,269,233,281,235,283,237,238,271,273,324,328,243,244,337,246,247,345,367,250,369,252,253,355,729],
"windows-1251":[1026,1027,8218,1107,8222,8230,8224,8225,8364,8240,1033,8249,1034,1036,1035,1039,1106,8216,8217,8220,8221,8226,8211,8212,152,8482,1113,8250,1114,1116,1115,1119,160,1038,1118,1032,164,1168,166,167,1025,169,1028,171,172,173,174,1031,176,177,1030,1110,1169,181,182,183,1105,8470,1108,187,1112,1029,1109,1111,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103],
"windows-1252":[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255],
"windows-1253":[8364,129,8218,402,8222,8230,8224,8225,136,8240,138,8249,140,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,152,8482,154,8250,156,157,158,159,160,901,902,163,164,165,166,167,168,169,null,171,172,173,174,8213,176,177,178,179,900,181,182,183,904,905,906,187,908,189,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,null,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,null],
"windows-1254":[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,158,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,286,209,210,211,212,213,214,215,216,217,218,219,220,304,350,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,287,241,242,243,244,245,246,247,248,249,250,251,252,305,351,255],
"windows-1255":[8364,129,8218,402,8222,8230,8224,8225,710,8240,138,8249,140,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,154,8250,156,157,158,159,160,161,162,163,8362,165,166,167,168,169,215,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,247,187,188,189,190,191,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1520,1521,1522,1523,1524,null,null,null,null,null,null,null,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,null,null,8206,8207,null],
"windows-1256":[8364,1662,8218,402,8222,8230,8224,8225,710,8240,1657,8249,338,1670,1688,1672,1711,8216,8217,8220,8221,8226,8211,8212,1705,8482,1681,8250,339,8204,8205,1722,160,1548,162,163,164,165,166,167,168,169,1726,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,1563,187,188,189,190,1567,1729,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,215,1591,1592,1593,1594,1600,1601,1602,1603,224,1604,226,1605,1606,1607,1608,231,232,233,234,235,1609,1610,238,239,1611,1612,1613,1614,244,1615,1616,247,1617,249,1618,251,252,8206,8207,1746],
"windows-1257":[8364,129,8218,131,8222,8230,8224,8225,136,8240,138,8249,140,168,711,184,144,8216,8217,8220,8221,8226,8211,8212,152,8482,154,8250,156,175,731,159,160,null,162,163,164,null,166,167,216,169,342,171,172,173,174,198,176,177,178,179,180,181,182,183,248,185,343,187,188,189,190,230,260,302,256,262,196,197,280,274,268,201,377,278,290,310,298,315,352,323,325,211,332,213,214,215,370,321,346,362,220,379,381,223,261,303,257,263,228,229,281,275,269,233,378,279,291,311,299,316,353,324,326,243,333,245,246,247,371,322,347,363,252,380,382,729],
"windows-1258":[8364,129,8218,402,8222,8230,8224,8225,710,8240,138,8249,338,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,154,8250,339,157,158,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,258,196,197,198,199,200,201,202,203,768,205,206,207,272,209,777,211,212,416,214,215,216,217,218,219,220,431,771,223,224,225,226,259,228,229,230,231,232,233,234,235,769,237,238,239,273,241,803,243,244,417,246,247,248,249,250,251,252,432,8363,255],
"x-mac-cyrillic":[1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,8224,176,1168,163,167,8226,182,1030,174,169,8482,1026,1106,8800,1027,1107,8734,177,8804,8805,1110,181,1169,1032,1028,1108,1031,1111,1033,1113,1034,1114,1112,1029,172,8730,402,8776,8710,171,187,8230,160,1035,1115,1036,1116,1109,8211,8212,8220,8221,8216,8217,247,8222,1038,1118,1039,1119,8470,1025,1105,1103,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,8364]
}
// For TextDecoder tests
var buffer = new ArrayBuffer(255),
view = new Uint8Array(buffer)
for(var i = 0, l = view.byteLength; i < l; i++) {
view[i] = i
}
// For XMLHttpRequest and TextDecoder tests
function assert_decode(data, encoding) {
if(encoding == "ISO-8859-8-I") {
encoding = "ISO-8859-8"
}
for(var i = 0, l = data.length; i < l; i++) {
var cp = data.charCodeAt(i),
expectedCp = (i < 0x80) ? i : singleByteIndexes[encoding][i-0x80]
if(expectedCp == null) {
expectedCp = 0xFFFD
}
assert_equals(cp, expectedCp, encoding + ":" + i)
}
}
var subsetTest = "";
if (location.search) {
subsetTest = location.search.substr(1);
}
// Setting up all the tests
for(var i = 0, l = singleByteEncodings.length; i < l; i++) {
var encoding = singleByteEncodings[i]
for(var ii = 0, ll = encoding.labels.length; ii < ll; ii++) {
var label = encoding.labels[ii]
if (subsetTest == "XMLHttpRequest" || !subsetTest) {
async_test(function(t) {
var xhr = new XMLHttpRequest,
name = encoding.name // need scoped variable
xhr.open("GET", "resources/single-byte-raw.py?label=" + label)
xhr.send(null)
xhr.onload = t.step_func_done(function() { assert_decode(xhr.responseText, name) })
}, encoding.name + ": " + label + " (XMLHttpRequest)")
}
if (subsetTest == "TextDecoder" || !subsetTest) {
test(function() {
var d = new TextDecoder(label),
data = d.decode(view)
assert_equals(d.encoding, encoding.name.toLowerCase()) // ASCII names only, so safe
assert_decode(data, encoding.name)
}, encoding.name + ": " + label + " (TextDecoder)")
}
if (subsetTest == "document" || !subsetTest) {
async_test(function(t) {
var frame = document.createElement("iframe"),
name = encoding.name;
frame.src = "resources/text-plain-charset.py?label=" + label
frame.onload = t.step_func_done(function() {
assert_equals(frame.contentDocument.characterSet, name)
assert_equals(frame.contentDocument.inputEncoding, name)
})
t.add_cleanup(function() { document.body.removeChild(frame) })
document.body.appendChild(frame)
}, encoding.name + ": " + label + " (document.characterSet and document.inputEncoding)")
}
}
}
</script>
@@ -1,18 +0,0 @@
<!doctype html>
<title>Negative timeout in setInterval</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({ single_test: true });
var i = 0;
var interval;
function next() {
i++;
if (i === 20) {
clearInterval(interval);
done();
}
}
setTimeout(assert_unreached, 1000);
interval = setInterval(next, -100);
</script>
@@ -1,9 +0,0 @@
<!doctype html>
<title>Negative timeout in setTimeout</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({ single_test: true });
setTimeout(done, -100);
setTimeout(assert_unreached, 10);
</script>
@@ -1,14 +0,0 @@
<!doctype html>
<title>Type long timeout for setInterval</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({ single_test: true });
var interval;
function next() {
clearInterval(interval);
done();
}
interval = setInterval(next, Math.pow(2, 32));
setTimeout(assert_unreached, 100);
</script>
@@ -1,9 +0,0 @@
<!doctype html>
<title>Type long timeout for setTimeout</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({ single_test: true });
setTimeout(done, Math.pow(2, 32));
setTimeout(assert_unreached, 100);
</script>
-3
View File
@@ -1,3 +0,0 @@
ROBIN-TODO.txt
scratch
node_modules
-30
View File
@@ -1,30 +0,0 @@
W3C 3-clause BSD License
http://www.w3.org/Consortium/Legal/2008/03-bsd-license.html
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of works must retain the original copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the original copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the W3C nor the names of its contributors may be
used to endorse or promote products derived from this work without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+4
View File
@@ -26,7 +26,11 @@ function assert_tolerance(actual, expected, message)
}
function checkDataKeys(node) {
// The purpose of this list of data-* attributes is simply to ensure typos
// in tests are caught. It is therefore "ok" to add to this list for
// specific tests.
var validData = new Set([
"data-anchor-polyfill",
"data-expected-width",
"data-expected-height",
"data-offset-x",
@@ -0,0 +1,24 @@
/*
* Polyfill for attaching shadow trees for declarative Shadow DOM for
* implementations that do not support declarative Shadow DOM.
*
* Note: this polyfill will feature-detect the native feature, and do nothing
* if supported.
*
* See: https://github.com/whatwg/html/pull/5465
*
* root: The root of the subtree in which to upgrade shadow roots
*
*/
function polyfill_declarative_shadow_dom(root) {
if (HTMLTemplateElement.prototype.hasOwnProperty('shadowRootMode'))
return;
root.querySelectorAll("template[shadowrootmode]").forEach(template => {
const mode = template.getAttribute("shadowrootmode");
const shadowRoot = template.parentNode.attachShadow({ mode });
shadowRoot.appendChild(template.content);
template.remove();
polyfill_declarative_shadow_dom(shadowRoot);
});
}
+20 -40
View File
@@ -21,11 +21,6 @@ function fetch_text(url) {
* dependency (i.e. have already been seen).
*/
function idl_test_shadowrealm(srcs, deps) {
const script_urls = [
"/resources/testharness.js",
"/resources/WebIDLParser.js",
"/resources/idlharness.js",
];
promise_setup(async t => {
const realm = new ShadowRealm();
// https://github.com/web-platform-tests/wpt/issues/31996
@@ -38,44 +33,29 @@ function idl_test_shadowrealm(srcs, deps) {
isShadowRealm: function() { return true; },
}; undefined;
`);
const ss = await Promise.all(script_urls.map(url => fetch_text(url)));
for (const s of ss) {
realm.evaluate(s);
}
const specs = await Promise.all(srcs.concat(deps).map(spec => {
return fetch_text("/interfaces/" + spec + ".idl");
}));
const idls = JSON.stringify(specs);
const results = JSON.parse(await new Promise(
realm.evaluate(`(resolve,reject) => {
const idls = ${idls};
add_completion_callback(function (tests, harness_status, asserts_run) {
resolve(JSON.stringify(tests));
});
// Without the wrapping test, testharness.js will think it's done after it has run
// the first idlharness test.
test(() => {
const idl_array = new IdlArray();
for (let i = 0; i < ${srcs.length}; i++) {
idl_array.add_idls(idls[i]);
}
for (let i = ${srcs.length}; i < ${srcs.length + deps.length}; i++) {
idl_array.add_dependency_idls(idls[i]);
}
idl_array.test();
}, "setup");
}`)
));
// We ran the tests in the ShadowRealm and gathered the results. Now treat them as if
// we'd run them directly here, so we can see them.
for (const {name, status, message} of results) {
// TODO: make this an API in testharness.js - needs RFC?
promise_test(t => {t.set_status(status, message); t.phase = t.phases.HAS_RESULT; t.done()}, name);
}
}, "outer setup");
await new Promise(
realm.evaluate(`(resolve,reject) => {
(async () => {
await import("/resources/testharness.js");
await import("/resources/WebIDLParser.js");
await import("/resources/idlharness.js");
const idls = ${idls};
const idl_array = new IdlArray();
for (let i = 0; i < ${srcs.length}; i++) {
idl_array.add_idls(idls[i]);
}
for (let i = ${srcs.length}; i < ${srcs.length + deps.length}; i++) {
idl_array.add_dependency_idls(idls[i]);
}
idl_array.test();
})().then(resolve, (e) => reject(e.toString()));
}`)
);
await fetch_tests_from_shadow_realm(realm);
});
}
// vim: set expandtab shiftwidth=4 tabstop=4 foldmarker=@{,@} foldmethod=marker:
+125 -98
View File
@@ -2433,44 +2433,6 @@ IdlInterface.prototype.test_to_json_operation = function(desc, memberHolderObjec
}
};
IdlInterface.prototype.test_member_iterable = function(member)
{
subsetTestByKey(this.name, test, function()
{
var isPairIterator = member.idlType.length === 2;
var proto = this.get_interface_object().prototype;
var iteratorDesc = Object.getOwnPropertyDescriptor(proto, Symbol.iterator);
assert_true(iteratorDesc.writable, "@@iterator property should be writable");
assert_true(iteratorDesc.configurable, "@@iterator property should be configurable");
assert_false(iteratorDesc.enumerable, "@@iterator property should not be enumerable");
assert_equals(typeof iteratorDesc.value, "function", "@@iterator property should be a function");
assert_equals(iteratorDesc.value.length, 0, "@@iterator function object length should be 0");
assert_equals(iteratorDesc.value.name, isPairIterator ? "entries" : "values", "@@iterator function object should have the right name");
if (isPairIterator) {
assert_equals(proto["entries"], proto[Symbol.iterator], "entries method should be the same as @@iterator method");
[
["entries", 0],
["keys", 0],
["values", 0],
["forEach", 1]
].forEach(([property, length]) => {
var desc = Object.getOwnPropertyDescriptor(proto, property);
assert_equals(typeof desc.value, "function", property + " property should be a function");
assert_equals(desc.value.length, length, property + " function object should have the right length");
assert_equals(desc.value.name, property, property + " function object should have the right name");
});
} else {
assert_equals(proto[Symbol.iterator], Array.prototype[Symbol.iterator], "@@iterator method should be the same as Array prototype's");
["entries", "keys", "values", "forEach", Symbol.iterator].forEach(property => {
var propertyName = property === Symbol.iterator ? "@@iterator" : property;
assert_equals(proto[property], Array.prototype[property], propertyName + " method should be the same as Array prototype's");
});
}
}.bind(this), this.name + " interface: iterable<" + member.idlType.map(function(t) { return t.idlType; }).join(", ") + ">");
};
IdlInterface.prototype.test_member_maplike = function(member) {
subsetTestByKey(this.name, test, () => {
const proto = this.get_interface_object().prototype;
@@ -2487,14 +2449,14 @@ IdlInterface.prototype.test_member_maplike = function(member) {
methods.push(
["set", 2],
["delete", 1],
["clear", 1]
["clear", 0]
);
}
for (const [name, length] of methods) {
const desc = Object.getOwnPropertyDescriptor(proto, name);
assert_equals(typeof desc.value, "function", `${name} should be a function`);
assert_equals(desc.enumerable, false, `${name} enumerable`);
assert_equals(desc.enumerable, true, `${name} enumerable`);
assert_equals(desc.configurable, true, `${name} configurable`);
assert_equals(desc.writable, true, `${name} writable`);
assert_equals(desc.value.length, length, `${name} function object length should be ${length}`);
@@ -2510,10 +2472,10 @@ IdlInterface.prototype.test_member_maplike = function(member) {
const sizeDesc = Object.getOwnPropertyDescriptor(proto, "size");
assert_equals(typeof sizeDesc.get, "function", `size getter should be a function`);
assert_equals(sizeDesc.set, undefined, `size should not have a setter`);
assert_equals(sizeDesc.enumerable, false, `size enumerable`);
assert_equals(sizeDesc.enumerable, true, `size enumerable`);
assert_equals(sizeDesc.configurable, true, `size configurable`);
assert_equals(sizeDesc.get.length, 0, `size getter length should have the right length`);
assert_equals(sizeDesc.get.name, "get size", `size getter have the right name`);
assert_equals(sizeDesc.get.length, 0, `size getter length`);
assert_equals(sizeDesc.get.name, "get size", `size getter name`);
}, `${this.name} interface: maplike<${member.idlType.map(t => t.idlType).join(", ")}>`);
};
@@ -2532,14 +2494,14 @@ IdlInterface.prototype.test_member_setlike = function(member) {
methods.push(
["add", 1],
["delete", 1],
["clear", 1]
["clear", 0]
);
}
for (const [name, length] of methods) {
const desc = Object.getOwnPropertyDescriptor(proto, name);
assert_equals(typeof desc.value, "function", `${name} should be a function`);
assert_equals(desc.enumerable, false, `${name} enumerable`);
assert_equals(desc.enumerable, true, `${name} enumerable`);
assert_equals(desc.configurable, true, `${name} configurable`);
assert_equals(desc.writable, true, `${name} writable`);
assert_equals(desc.value.length, length, `${name} function object length should be ${length}`);
@@ -2555,42 +2517,92 @@ IdlInterface.prototype.test_member_setlike = function(member) {
const sizeDesc = Object.getOwnPropertyDescriptor(proto, "size");
assert_equals(typeof sizeDesc.get, "function", `size getter should be a function`);
assert_equals(sizeDesc.set, undefined, `size should not have a setter`);
assert_equals(sizeDesc.enumerable, false, `size enumerable`);
assert_equals(sizeDesc.enumerable, true, `size enumerable`);
assert_equals(sizeDesc.configurable, true, `size configurable`);
assert_equals(sizeDesc.get.length, 0, `size getter length should have the right length`);
assert_equals(sizeDesc.get.name, "size", `size getter have the right name`);
assert_equals(sizeDesc.get.length, 0, `size getter length`);
assert_equals(sizeDesc.get.name, "get size", `size getter name`);
}, `${this.name} interface: setlike<${member.idlType.map(t => t.idlType).join(", ")}>`);
};
IdlInterface.prototype.test_member_async_iterable = function(member)
{
subsetTestByKey(this.name, test, function()
{
var isPairIterator = member.idlType.length === 2;
var proto = this.get_interface_object().prototype;
var iteratorDesc = Object.getOwnPropertyDescriptor(proto, Symbol.asyncIterator);
IdlInterface.prototype.test_member_iterable = function(member) {
subsetTestByKey(this.name, test, () => {
const isPairIterator = member.idlType.length === 2;
const proto = this.get_interface_object().prototype;
assert_true(iteratorDesc.writable, "@@asyncIterator property should be writable");
assert_true(iteratorDesc.configurable, "@@asyncIterator property should be configurable");
assert_false(iteratorDesc.enumerable, "@@asyncIterator property should not be enumerable");
assert_equals(typeof iteratorDesc.value, "function", "@@asyncIterator property should be a function");
assert_equals(iteratorDesc.value.length, 0, "@@asyncIterator function object length should be 0");
assert_equals(iteratorDesc.value.name, isPairIterator ? "entries" : "values", "@@asyncIterator function object should have the right name");
const methods = [
["entries", 0],
["keys", 0],
["values", 0],
["forEach", 1]
];
for (const [name, length] of methods) {
const desc = Object.getOwnPropertyDescriptor(proto, name);
assert_equals(typeof desc.value, "function", `${name} should be a function`);
assert_equals(desc.enumerable, true, `${name} enumerable`);
assert_equals(desc.configurable, true, `${name} configurable`);
assert_equals(desc.writable, true, `${name} writable`);
assert_equals(desc.value.length, length, `${name} function object length should be ${length}`);
assert_equals(desc.value.name, name, `${name} function object should have the right name`);
if (!isPairIterator) {
assert_equals(desc.value, Array.prototype[name], `${name} equality with Array.prototype version`);
}
}
const iteratorDesc = Object.getOwnPropertyDescriptor(proto, Symbol.iterator);
assert_equals(iteratorDesc.enumerable, false, `@@iterator enumerable`);
assert_equals(iteratorDesc.configurable, true, `@@iterator configurable`);
assert_equals(iteratorDesc.writable, true, `@@iterator writable`);
if (isPairIterator) {
assert_equals(proto["entries"], proto[Symbol.asyncIterator], "entries method should be the same as @@asyncIterator method");
["entries", "keys", "values"].forEach(property => {
var desc = Object.getOwnPropertyDescriptor(proto, property);
assert_equals(typeof desc.value, "function", property + " property should be a function");
assert_equals(desc.value.length, 0, property + " function object length should be 0");
assert_equals(desc.value.name, property, property + " function object should have the right name");
});
assert_equals(iteratorDesc.value, proto.entries, `@@iterator equality with entries`);
} else {
assert_equals(proto["values"], proto[Symbol.asyncIterator], "values method should be the same as @@asyncIterator method");
assert_false("entries" in proto, "should not have an entries method");
assert_false("keys" in proto, "should not have a keys method");
assert_equals(iteratorDesc.value, Array.prototype[Symbol.iterator], `@@iterator equality with Array.prototype version`);
}
}.bind(this), this.name + " interface: async iterable<" + member.idlType.map(function(t) { return t.idlType; }).join(", ") + ">");
}, `${this.name} interface: iterable<${member.idlType.map(t => t.idlType).join(", ")}>`);
};
IdlInterface.prototype.test_member_async_iterable = function(member) {
subsetTestByKey(this.name, test, () => {
const isPairIterator = member.idlType.length === 2;
const proto = this.get_interface_object().prototype;
// Note that although the spec allows arguments, which will be passed to the @@asyncIterator
// method (which is either values or entries), those arguments must always be optional. So
// length of 0 is still correct for values and entries.
const methods = [
["values", 0],
];
if (isPairIterator) {
methods.push(
["entries", 0],
["keys", 0]
);
}
for (const [name, length] of methods) {
const desc = Object.getOwnPropertyDescriptor(proto, name);
assert_equals(typeof desc.value, "function", `${name} should be a function`);
assert_equals(desc.enumerable, true, `${name} enumerable`);
assert_equals(desc.configurable, true, `${name} configurable`);
assert_equals(desc.writable, true, `${name} writable`);
assert_equals(desc.value.length, length, `${name} function object length should be ${length}`);
assert_equals(desc.value.name, name, `${name} function object should have the right name`);
}
const iteratorDesc = Object.getOwnPropertyDescriptor(proto, Symbol.asyncIterator);
assert_equals(iteratorDesc.enumerable, false, `@@iterator enumerable`);
assert_equals(iteratorDesc.configurable, true, `@@iterator configurable`);
assert_equals(iteratorDesc.writable, true, `@@iterator writable`);
if (isPairIterator) {
assert_equals(iteratorDesc.value, proto.entries, `@@iterator equality with entries`);
} else {
assert_equals(iteratorDesc.value, proto.values, `@@iterator equality with values`);
}
}, `${this.name} interface: async iterable<${member.idlType.map(t => t.idlType).join(", ")}>`);
};
IdlInterface.prototype.test_member_stringifier = function(member)
@@ -2656,6 +2668,7 @@ IdlInterface.prototype.test_member_stringifier = function(member)
IdlInterface.prototype.test_members = function()
{
var unexposed_members = new Set();
for (var i = 0; i < this.members.length; i++)
{
var member = this.members[i];
@@ -2664,15 +2677,18 @@ IdlInterface.prototype.test_members = function()
}
if (!exposed_in(exposure_set(member, this.exposureSet))) {
subsetTestByKey(this.name, test, function() {
// It's not exposed, so we shouldn't find it anywhere.
assert_false(member.name in this.get_interface_object(),
"The interface object must not have a property " +
format_value(member.name));
assert_false(member.name in this.get_interface_object().prototype,
"The prototype object must not have a property " +
format_value(member.name));
}.bind(this), this.name + " interface: member " + member.name);
if (!unexposed_members.has(member.name)) {
unexposed_members.add(member.name);
subsetTestByKey(this.name, test, function() {
// It's not exposed, so we shouldn't find it anywhere.
assert_false(member.name in this.get_interface_object(),
"The interface object must not have a property " +
format_value(member.name));
assert_false(member.name in this.get_interface_object().prototype,
"The prototype object must not have a property " +
format_value(member.name));
}.bind(this), this.name + " interface: member " + member.name);
}
continue;
}
@@ -2751,21 +2767,26 @@ IdlInterface.prototype.test_object = function(desc)
expected_typeof = "object";
}
this.test_primary_interface_of(desc, obj, exception, expected_typeof);
if (this.is_callback()) {
assert_equals(exception, null, "Unexpected exception when evaluating object");
assert_equals(typeof obj, expected_typeof, "wrong typeof object");
} else {
this.test_primary_interface_of(desc, obj, exception, expected_typeof);
var current_interface = this;
while (current_interface)
{
if (!(current_interface.name in this.array.members))
var current_interface = this;
while (current_interface)
{
throw new IdlHarnessError("Interface " + current_interface.name + " not found (inherited by " + this.name + ")");
if (!(current_interface.name in this.array.members))
{
throw new IdlHarnessError("Interface " + current_interface.name + " not found (inherited by " + this.name + ")");
}
if (current_interface.prevent_multiple_testing && current_interface.already_tested)
{
return;
}
current_interface.test_interface_of(desc, obj, exception, expected_typeof);
current_interface = this.array.members[current_interface.base];
}
if (current_interface.prevent_multiple_testing && current_interface.already_tested)
{
return;
}
current_interface.test_interface_of(desc, obj, exception, expected_typeof);
current_interface = this.array.members[current_interface.base];
}
};
@@ -2838,17 +2859,23 @@ IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expect
return;
}
var unexposed_properties = new Set();
for (var i = 0; i < this.members.length; i++)
{
var member = this.members[i];
if (member.untested) {
continue;
}
if (!exposed_in(exposure_set(member, this.exposureSet))) {
subsetTestByKey(this.name, test, function() {
assert_equals(exception, null, "Unexpected exception when evaluating object");
assert_false(member.name in obj);
}.bind(this), this.name + " interface: " + desc + ' must not have property "' + member.name + '"');
if (!exposed_in(exposure_set(member, this.exposureSet)))
{
if (!unexposed_properties.has(member.name))
{
unexposed_properties.add(member.name);
subsetTestByKey(this.name, test, function() {
assert_equals(exception, null, "Unexpected exception when evaluating object");
assert_false(member.name in obj);
}.bind(this), this.name + " interface: " + desc + ' must not have property "' + member.name + '"');
}
continue;
}
if (member.type == "attribute" && member.isUnforgeable)
+51 -9
View File
@@ -78,8 +78,8 @@
* Trigger user interaction in order to grant additional privileges to
* a provided function.
*
* See `triggered by user activation
* <https://html.spec.whatwg.org/#triggered-by-user-activation>`_.
* See `Tracking user activation
* <https://html.spec.whatwg.org/multipage/interaction.html#tracking-user-activation>`_.
*
* @example
* var mediaElement = document.createElement('video');
@@ -184,6 +184,42 @@
return window.test_driver_internal.delete_all_cookies(context);
},
/**
* Get details for all cookies in the current context.
* See https://w3c.github.io/webdriver/#get-all-cookies
*
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
*
* @returns {Promise} Returns an array of cookies objects as defined in the spec:
* https://w3c.github.io/webdriver/#cookies
*/
get_all_cookies: function(context=null) {
return window.test_driver_internal.get_all_cookies(context);
},
/**
* Get details for a cookie in the current context by name if it exists.
* See https://w3c.github.io/webdriver/#get-named-cookie
*
* @param {String} name - The name of the cookie to get.
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
*
* @returns {Promise} Returns the matching cookie as defined in the spec:
* https://w3c.github.io/webdriver/#cookies
* Rejected if no such cookie exists.
*/
get_named_cookie: async function(name, context=null) {
let cookie = await window.test_driver_internal.get_named_cookie(name, context);
if (!cookie) {
throw new Error("no such cookie");
}
return cookie;
},
/**
* Send keys to an element.
*
@@ -362,24 +398,22 @@
*
* @example
* await test_driver.set_permission({ name: "background-fetch" }, "denied");
* await test_driver.set_permission({ name: "push", userVisibleOnly: true }, "granted", true);
* await test_driver.set_permission({ name: "push", userVisibleOnly: true }, "granted");
*
* @param {Object} descriptor - a `PermissionDescriptor
* <https://w3c.github.io/permissions/#dictdef-permissiondescriptor>`_
* object
* @param {PermissionDescriptor} descriptor - a `PermissionDescriptor
* <https://w3c.github.io/permissions/#dom-permissiondescriptor>`_
* dictionary.
* @param {String} state - the state of the permission
* @param {boolean} one_realm - Optional. Whether the permission applies to only one realm
* @param {WindowProxy} context - Browsing context in which
* to run the call, or null for the current
* browsing context.
* @returns {Promise} fulfilled after the permission is set, or rejected if setting the
* permission fails
*/
set_permission: function(descriptor, state, one_realm=false, context=null) {
set_permission: function(descriptor, state, context=null) {
let permission_params = {
descriptor,
state,
oneRealm: one_realm,
};
return window.test_driver_internal.set_permission(permission_params, context);
},
@@ -637,6 +671,14 @@
return Promise.reject(new Error("unimplemented"));
},
get_all_cookies: function(context=null) {
return Promise.reject(new Error("unimplemented"));
},
get_named_cookie: function(name, context=null) {
return Promise.reject(new Error("unimplemented"));
},
send_keys: function(element, keys) {
if (this.in_automation) {
return Promise.reject(new Error('Not implemented'));
-2
View File
@@ -1,2 +0,0 @@
Content-Type: text/css;charset=utf-8
Cache-Control: max-age=3600
+27 -6
View File
@@ -494,7 +494,7 @@
ShellTestEnvironment.prototype.next_default_test_name = function() {
var suffix = this.name_counter > 0 ? " " + this.name_counter : "";
this.name_counter++;
return "Untitled" + suffix;
return get_title() + suffix;
};
ShellTestEnvironment.prototype.on_new_harness_properties = function() {};
@@ -2246,7 +2246,8 @@
ReadOnlyError: 0,
VersionError: 0,
OperationError: 0,
NotAllowedError: 0
NotAllowedError: 0,
OptOutError: 0
};
var code_name_map = {};
@@ -2477,6 +2478,10 @@
this._user_defined_cleanup_count = 0;
this._done_callbacks = [];
if (typeof AbortController === "function") {
this._abortController = new AbortController();
}
// Tests declared following harness completion are likely an indication
// of a programming error, but they cannot be reported
// deterministically.
@@ -2953,6 +2958,10 @@
this.phase = this.phases.CLEANING;
if (this._abortController) {
this._abortController.abort("Test cleanup");
}
forEach(this.cleanup_callbacks,
function(cleanup_callback) {
var result;
@@ -3046,6 +3055,16 @@
test._done_callbacks.length = 0;
}
/**
* Gives an AbortSignal that will be aborted when the test finishes.
*/
Test.prototype.get_signal = function() {
if (!this._abortController) {
throw new Error("AbortController is not supported in this browser");
}
return this._abortController.signal;
}
/**
* A RemoteTest object mirrors a Test object on a remote worker. The
* associated RemoteWorker updates the RemoteTest object in response to
@@ -3822,7 +3841,9 @@
return;
}
this.pending_remotes.push(this.create_remote_window(remote));
var remoteContext = this.create_remote_window(remote);
this.pending_remotes.push(remoteContext);
return remoteContext.done;
};
/**
@@ -3837,7 +3858,7 @@
* @param {Window} window - The window to fetch tests from.
*/
function fetch_tests_from_window(window) {
tests.fetch_tests_from_window(window);
return tests.fetch_tests_from_window(window);
}
expose(fetch_tests_from_window, 'fetch_tests_from_window');
@@ -3871,7 +3892,7 @@
*/
function begin_shadow_realm_tests(postMessage) {
if (!(test_environment instanceof ShadowRealmTestEnvironment)) {
throw new Error("beign_shadow_realm_tests called in non-Shadow Realm environment");
throw new Error("begin_shadow_realm_tests called in non-Shadow Realm environment");
}
test_environment.begin(function (msg) {
@@ -4733,7 +4754,7 @@
if ('META_TITLE' in global_scope && META_TITLE) {
return META_TITLE;
}
if ('location' in global_scope) {
if ('location' in global_scope && 'pathname' in location) {
return location.pathname.substring(location.pathname.lastIndexOf('/') + 1, location.pathname.indexOf('.'));
}
return "Untitled";
@@ -1,4 +0,0 @@
scratch
node_modules
lib-cov
browser-tests.html
-5
View File
@@ -1,5 +0,0 @@
language: node_js
node_js:
- node
- lts/*
- 6
-292
View File
@@ -1,292 +0,0 @@
# Change Log
## [v10.2.1](https://github.com/w3c/webidl2.js/tree/v10.2.1) (2018-03-09)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v10.2.0...v10.2.1)
**Merged pull requests:**
- Optimise tokenisation and whitespace skipping [\#139](https://github.com/w3c/webidl2.js/pull/139) ([ricea](https://github.com/ricea))
- refactor: small syntax changes [\#137](https://github.com/w3c/webidl2.js/pull/137) ([saschanaz](https://github.com/saschanaz))
## [v10.2.0](https://github.com/w3c/webidl2.js/tree/v10.2.0) (2018-01-30)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v10.1.0...v10.2.0)
**Merged pull requests:**
- Type on union idlType [\#135](https://github.com/w3c/webidl2.js/pull/135) ([saschanaz](https://github.com/saschanaz))
- feat: add argument/return type [\#134](https://github.com/w3c/webidl2.js/pull/134) ([saschanaz](https://github.com/saschanaz))
- feat: add dictionary/typedef-type [\#133](https://github.com/w3c/webidl2.js/pull/133) ([saschanaz](https://github.com/saschanaz))
- feat: add const-type for idlTypes [\#132](https://github.com/w3c/webidl2.js/pull/132) ([saschanaz](https://github.com/saschanaz))
- feat: add types on idlTypes [\#131](https://github.com/w3c/webidl2.js/pull/131) ([saschanaz](https://github.com/saschanaz))
- Auto acquisition for parser result changes [\#130](https://github.com/w3c/webidl2.js/pull/130) ([saschanaz](https://github.com/saschanaz))
## [v10.1.0](https://github.com/w3c/webidl2.js/tree/v10.1.0) (2018-01-19)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v10.0.0...v10.1.0)
**Closed issues:**
- Support `raises` and `setraises` [\#128](https://github.com/w3c/webidl2.js/issues/128)
- Support `legacycaller` [\#127](https://github.com/w3c/webidl2.js/issues/127)
- Improve "No semicolon after enum" message [\#119](https://github.com/w3c/webidl2.js/issues/119)
**Merged pull requests:**
- Let error messages include the current definition name [\#129](https://github.com/w3c/webidl2.js/pull/129) ([saschanaz](https://github.com/saschanaz))
## [v10.0.0](https://github.com/w3c/webidl2.js/tree/v10.0.0) (2017-12-20)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v9.0.0...v10.0.0)
**Closed issues:**
- Always return an array for idlType, etc. [\#113](https://github.com/w3c/webidl2.js/issues/113)
- Maintain writer.js or not? [\#109](https://github.com/w3c/webidl2.js/issues/109)
**Merged pull requests:**
- Remove typeExtAttrs from docs [\#124](https://github.com/w3c/webidl2.js/pull/124) ([saschanaz](https://github.com/saschanaz))
- Remove iterator documentation [\#123](https://github.com/w3c/webidl2.js/pull/123) ([saschanaz](https://github.com/saschanaz))
- Maintain writer.js [\#122](https://github.com/w3c/webidl2.js/pull/122) ([saschanaz](https://github.com/saschanaz))
- BREAKING CHANGE: remove deprecated iterator operation [\#121](https://github.com/w3c/webidl2.js/pull/121) ([saschanaz](https://github.com/saschanaz))
- Use for-of on tests [\#120](https://github.com/w3c/webidl2.js/pull/120) ([saschanaz](https://github.com/saschanaz))
- docs\(README\): iterables ildType is always array [\#118](https://github.com/w3c/webidl2.js/pull/118) ([marcoscaceres](https://github.com/marcoscaceres))
## [v9.0.0](https://github.com/w3c/webidl2.js/tree/v9.0.0) (2017-11-30)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v8.1.0...v9.0.0)
**Closed issues:**
- Code quality [\#116](https://github.com/w3c/webidl2.js/issues/116)
- Unable to parse HTMLAllCollection interface [\#114](https://github.com/w3c/webidl2.js/issues/114)
- Add support for mixin syntax [\#112](https://github.com/w3c/webidl2.js/issues/112)
- Whitespace issues [\#111](https://github.com/w3c/webidl2.js/issues/111)
**Merged pull requests:**
- Consistent array type for iterable.idlType [\#117](https://github.com/w3c/webidl2.js/pull/117) ([saschanaz](https://github.com/saschanaz))
- Revert "chore: drop Node 6 support \(\#102\)" [\#115](https://github.com/w3c/webidl2.js/pull/115) ([TimothyGu](https://github.com/TimothyGu))
## [v8.1.0](https://github.com/w3c/webidl2.js/tree/v8.1.0) (2017-11-03)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v8.0.1...v8.1.0)
**Closed issues:**
- Extended Attributes `rhs` should always be there [\#96](https://github.com/w3c/webidl2.js/issues/96)
**Merged pull requests:**
- Always add rhs property [\#110](https://github.com/w3c/webidl2.js/pull/110) ([saschanaz](https://github.com/saschanaz))
## [v8.0.1](https://github.com/w3c/webidl2.js/tree/v8.0.1) (2017-11-03)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v8.0.0...v8.0.1)
**Fixed bugs:**
- Comment order parsing bug [\#107](https://github.com/w3c/webidl2.js/issues/107)
**Merged pull requests:**
- Remove m postfix from all\_ws\(\) [\#108](https://github.com/w3c/webidl2.js/pull/108) ([saschanaz](https://github.com/saschanaz))
## [v8.0.0](https://github.com/w3c/webidl2.js/tree/v8.0.0) (2017-11-03)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v7.0.0...v8.0.0)
**Closed issues:**
- Remove creators support [\#100](https://github.com/w3c/webidl2.js/issues/100)
- Add mixin support [\#92](https://github.com/w3c/webidl2.js/issues/92)
**Merged pull requests:**
- Support mixins + includes statements [\#105](https://github.com/w3c/webidl2.js/pull/105) ([saschanaz](https://github.com/saschanaz))
- chore: drop Node 6 support [\#102](https://github.com/w3c/webidl2.js/pull/102) ([marcoscaceres](https://github.com/marcoscaceres))
- BREAKING CHANGE: drop creator support [\#101](https://github.com/w3c/webidl2.js/pull/101) ([saschanaz](https://github.com/saschanaz))
- Normalize some whitespace to pass wpt's lint [\#99](https://github.com/w3c/webidl2.js/pull/99) ([foolip](https://github.com/foolip))
## [v7.0.0](https://github.com/w3c/webidl2.js/tree/v7.0.0) (2017-10-27)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v6.1.0...v7.0.0)
**Closed issues:**
- Type conversion on default values is destructive [\#94](https://github.com/w3c/webidl2.js/issues/94)
- extended attribute structure missing type [\#89](https://github.com/w3c/webidl2.js/issues/89)
**Merged pull requests:**
- BREAKING CHANGE: argument + default types should be string [\#95](https://github.com/w3c/webidl2.js/pull/95) ([marcoscaceres](https://github.com/marcoscaceres))
## [v6.1.0](https://github.com/w3c/webidl2.js/tree/v6.1.0) (2017-10-23)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v6.0.1...v6.1.0)
**Merged pull requests:**
- feat: give extended attributes a type [\#90](https://github.com/w3c/webidl2.js/pull/90) ([marcoscaceres](https://github.com/marcoscaceres))
## [v6.0.1](https://github.com/w3c/webidl2.js/tree/v6.0.1) (2017-10-18)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v6.0.0...v6.0.1)
**Closed issues:**
- Enum values should be objects [\#86](https://github.com/w3c/webidl2.js/issues/86)
**Merged pull requests:**
- Use ES2015 syntax for tests [\#88](https://github.com/w3c/webidl2.js/pull/88) ([saschanaz](https://github.com/saschanaz))
## [v6.0.0](https://github.com/w3c/webidl2.js/tree/v6.0.0) (2017-10-17)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v5.0.0...v6.0.0)
**Merged pull requests:**
- BREAKING CHANGE: ret enum value as object [\#87](https://github.com/w3c/webidl2.js/pull/87) ([marcoscaceres](https://github.com/marcoscaceres))
## [v5.0.0](https://github.com/w3c/webidl2.js/tree/v5.0.0) (2017-10-17)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v4.2.0...v5.0.0)
**Closed issues:**
- Unable to parse annotated types in generics [\#83](https://github.com/w3c/webidl2.js/issues/83)
- Drop support for Node 4, move to 6 LTS [\#82](https://github.com/w3c/webidl2.js/issues/82)
**Merged pull requests:**
- BREAKING CHANGE: Use ES2015 syntax [\#84](https://github.com/w3c/webidl2.js/pull/84) ([saschanaz](https://github.com/saschanaz))
## [v4.2.0](https://github.com/w3c/webidl2.js/tree/v4.2.0) (2017-10-16)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v4.1.0...v4.2.0)
**Closed issues:**
- Remove legacy caller support [\#78](https://github.com/w3c/webidl2.js/issues/78)
- Should report error for using duplicate names [\#77](https://github.com/w3c/webidl2.js/issues/77)
**Merged pull requests:**
- Check duplicated names [\#80](https://github.com/w3c/webidl2.js/pull/80) ([saschanaz](https://github.com/saschanaz))
- Remove legacycaller [\#79](https://github.com/w3c/webidl2.js/pull/79) ([saschanaz](https://github.com/saschanaz))
- Add "sequence" property to IDL Type AST definition [\#76](https://github.com/w3c/webidl2.js/pull/76) ([lerouche](https://github.com/lerouche))
## [v4.1.0](https://github.com/w3c/webidl2.js/tree/v4.1.0) (2017-07-04)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v4.0.0...v4.1.0)
**Closed issues:**
- Parsing error for annonated inner types of generic types [\#71](https://github.com/w3c/webidl2.js/issues/71)
**Merged pull requests:**
- Support TypeWithExtendedAttributes on generics [\#75](https://github.com/w3c/webidl2.js/pull/75) ([saschanaz](https://github.com/saschanaz))
## [v4.0.0](https://github.com/w3c/webidl2.js/tree/v4.0.0) (2017-06-27)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v3.0.2...v4.0.0)
**Closed issues:**
- Remove serializer-related productions [\#73](https://github.com/w3c/webidl2.js/issues/73)
- Records don't seem to be working right [\#72](https://github.com/w3c/webidl2.js/issues/72)
- Document namespace member output [\#59](https://github.com/w3c/webidl2.js/issues/59)
**Merged pull requests:**
- BREAKING CHANGE: remove serializers \(closes \#73\) [\#74](https://github.com/w3c/webidl2.js/pull/74) ([marcoscaceres](https://github.com/marcoscaceres))
- Add documentation for namespaces [\#70](https://github.com/w3c/webidl2.js/pull/70) ([saschanaz](https://github.com/saschanaz))
## [v3.0.2](https://github.com/w3c/webidl2.js/tree/v3.0.2) (2017-05-29)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v3.0.1...v3.0.2)
**Closed issues:**
- Whitespace issues [\#64](https://github.com/w3c/webidl2.js/issues/64)
**Merged pull requests:**
- Test for latest LTS/stable node versions [\#69](https://github.com/w3c/webidl2.js/pull/69) ([saschanaz](https://github.com/saschanaz))
## [v3.0.1](https://github.com/w3c/webidl2.js/tree/v3.0.1) (2017-05-18)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v2.4.0...v3.0.1)
**Closed issues:**
- Is array syntax dead? [\#66](https://github.com/w3c/webidl2.js/issues/66)
- Remove exceptions support [\#65](https://github.com/w3c/webidl2.js/issues/65)
**Merged pull requests:**
- Fix whitespace error on parsing extended attributes [\#68](https://github.com/w3c/webidl2.js/pull/68) ([saschanaz](https://github.com/saschanaz))
- Remove deprecated IDL arrays and exceptions [\#67](https://github.com/w3c/webidl2.js/pull/67) ([saschanaz](https://github.com/saschanaz))
## [v2.4.0](https://github.com/w3c/webidl2.js/tree/v2.4.0) (2017-04-12)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v2.1.0...v2.4.0)
**Closed issues:**
- Add support for Annotated Types [\#60](https://github.com/w3c/webidl2.js/issues/60)
- Question: Convert WebIDL -\> Javascript [\#56](https://github.com/w3c/webidl2.js/issues/56)
- Get Robin to give us push permissions on npm [\#54](https://github.com/w3c/webidl2.js/issues/54)
- Add support for records [\#53](https://github.com/w3c/webidl2.js/issues/53)
- module not supported? [\#52](https://github.com/w3c/webidl2.js/issues/52)
- Add support for namespaces [\#51](https://github.com/w3c/webidl2.js/issues/51)
- Export is not AMD compatible [\#48](https://github.com/w3c/webidl2.js/issues/48)
- Can't represent large constants [\#21](https://github.com/w3c/webidl2.js/issues/21)
**Merged pull requests:**
- Update webidl2.js [\#63](https://github.com/w3c/webidl2.js/pull/63) ([tqeto](https://github.com/tqeto))
- Remove support for MapClass \(no longer valid in WebIDL\) [\#62](https://github.com/w3c/webidl2.js/pull/62) ([dontcallmedom](https://github.com/dontcallmedom))
- Add support for annotated types [\#61](https://github.com/w3c/webidl2.js/pull/61) ([dontcallmedom](https://github.com/dontcallmedom))
- Support namespaces [\#58](https://github.com/w3c/webidl2.js/pull/58) ([saschanaz](https://github.com/saschanaz))
- Add support for records [\#57](https://github.com/w3c/webidl2.js/pull/57) ([TimothyGu](https://github.com/TimothyGu))
- Refactor [\#50](https://github.com/w3c/webidl2.js/pull/50) ([marcoscaceres](https://github.com/marcoscaceres))
- feat\(lib\): add AMD export support \(closes \#48\) [\#49](https://github.com/w3c/webidl2.js/pull/49) ([marcoscaceres](https://github.com/marcoscaceres))
## [v2.1.0](https://github.com/w3c/webidl2.js/tree/v2.1.0) (2016-08-12)
**Closed issues:**
- Exception when parsing test/syntax/idl/typedef.widl [\#46](https://github.com/w3c/webidl2.js/issues/46)
- Wrong jsondiffpatch location [\#42](https://github.com/w3c/webidl2.js/issues/42)
- 'npm install' fails on building microtime [\#40](https://github.com/w3c/webidl2.js/issues/40)
- Can't represent union types in typedefs [\#38](https://github.com/w3c/webidl2.js/issues/38)
- tokenise\(\) assumes a specific property enumeration order [\#27](https://github.com/w3c/webidl2.js/issues/27)
- Add support for iterable\<\>, maplike\<\>, setlike\<\> declarations [\#24](https://github.com/w3c/webidl2.js/issues/24)
- WebIDL2 fails to parse `attribute Promise\<DOMString\>\[\] baz` [\#19](https://github.com/w3c/webidl2.js/issues/19)
- Support for ExtendedAttributeIdentList \(current editor's draft\) [\#18](https://github.com/w3c/webidl2.js/issues/18)
- No Licensing Information [\#17](https://github.com/w3c/webidl2.js/issues/17)
- how to regenerate w3c idl files ? [\#14](https://github.com/w3c/webidl2.js/issues/14)
- What is lib/writer.js [\#13](https://github.com/w3c/webidl2.js/issues/13)
- Numerous tests are failing [\#7](https://github.com/w3c/webidl2.js/issues/7)
- Add support for missing types in ServiceWorker [\#5](https://github.com/w3c/webidl2.js/issues/5)
- How can I parse just a function? [\#3](https://github.com/w3c/webidl2.js/issues/3)
- Parser throws on nullable array of nullable array [\#2](https://github.com/w3c/webidl2.js/issues/2)
- Parser throws on nullable array of any [\#1](https://github.com/w3c/webidl2.js/issues/1)
**Merged pull requests:**
- Fix "default": undefined [\#47](https://github.com/w3c/webidl2.js/pull/47) ([mkwtys](https://github.com/mkwtys))
- Replace expect.js with expct [\#45](https://github.com/w3c/webidl2.js/pull/45) ([halton](https://github.com/halton))
- Correct jsondiffpatch location. [\#44](https://github.com/w3c/webidl2.js/pull/44) ([halton](https://github.com/halton))
- Bump microtime to 2.1.1 [\#43](https://github.com/w3c/webidl2.js/pull/43) ([halton](https://github.com/halton))
- Expand writer support [\#39](https://github.com/w3c/webidl2.js/pull/39) ([markandrus](https://github.com/markandrus))
- Accept wider \(but still incomplete\) set of allowed syntax for extended attributes [\#37](https://github.com/w3c/webidl2.js/pull/37) ([mlogan](https://github.com/mlogan))
- Add test for callback with multiple arguments. [\#36](https://github.com/w3c/webidl2.js/pull/36) ([tobie](https://github.com/tobie))
- Iterables [\#34](https://github.com/w3c/webidl2.js/pull/34) ([motiz88](https://github.com/motiz88))
- Allow trailing comma in enum value lists, per spec [\#33](https://github.com/w3c/webidl2.js/pull/33) ([motiz88](https://github.com/motiz88))
- Allow typedefs within interfaces \(behind an opt-in flag\) [\#32](https://github.com/w3c/webidl2.js/pull/32) ([motiz88](https://github.com/motiz88))
- In draft [\#31](https://github.com/w3c/webidl2.js/pull/31) ([othree](https://github.com/othree))
- Add support for extended attributes identifier lists [\#29](https://github.com/w3c/webidl2.js/pull/29) ([tobie](https://github.com/tobie))
- Make `attribute Promise\<T\>\[\] attr;` work. [\#26](https://github.com/w3c/webidl2.js/pull/26) ([jyasskin](https://github.com/jyasskin))
- Parse required dictionary fields. [\#25](https://github.com/w3c/webidl2.js/pull/25) ([jyasskin](https://github.com/jyasskin))
- Define the WebIDL2 property on self rather than window. [\#23](https://github.com/w3c/webidl2.js/pull/23) ([Ms2ger](https://github.com/Ms2ger))
- Teach WebIDL2 to parse \[\] default values. [\#22](https://github.com/w3c/webidl2.js/pull/22) ([jyasskin](https://github.com/jyasskin))
- Support ID list in extended attributes [\#20](https://github.com/w3c/webidl2.js/pull/20) ([othree](https://github.com/othree))
- Make sure that `sequence` property of idl types is set to false if the type is actually `sequence`. [\#16](https://github.com/w3c/webidl2.js/pull/16) ([tobie](https://github.com/tobie))
- Parametrized [\#15](https://github.com/w3c/webidl2.js/pull/15) ([tobie](https://github.com/tobie))
- Add promise support [\#12](https://github.com/w3c/webidl2.js/pull/12) ([tobie](https://github.com/tobie))
- Remove broken coverage support from travis for now. [\#11](https://github.com/w3c/webidl2.js/pull/11) ([tobie](https://github.com/tobie))
- Add support for \[MapClass\(type, type\)\]. [\#10](https://github.com/w3c/webidl2.js/pull/10) ([tobie](https://github.com/tobie))
- Incorporate tests from widlproc\[1\] and remove dependency on said project. [\#9](https://github.com/w3c/webidl2.js/pull/9) ([tobie](https://github.com/tobie))
- README incorrectly recommended updating the widlproc submodule. [\#8](https://github.com/w3c/webidl2.js/pull/8) ([tobie](https://github.com/tobie))
- Fix bug where instrumented version of webidl2 was loaded. [\#6](https://github.com/w3c/webidl2.js/pull/6) ([tobie](https://github.com/tobie))
- Use https:// instead of git:// [\#4](https://github.com/w3c/webidl2.js/pull/4) ([Manishearth](https://github.com/Manishearth))
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
-21
View File
@@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014 Robin Berjon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-629
View File
@@ -1,629 +0,0 @@
# WebIDL 2
[![NPM version](https://badge.fury.io/js/webidl2.svg)](http://badge.fury.io/js/webidl2)
## Purpose
This is a parser for the [WebIDL](http://dev.w3.org/2006/webapi/WebIDL/) language. If
you don't know what that is, then you probably don't need it. It is meant to be used
both in Node and in the browser (the parser likely works in other JS environments, but
not the test suite).
## Installation
Just the usual. For Node:
```Bash
npm install webidl2
```
In the browser:
```HTML
<script src='webidl2.js'></script>
```
## Documentation
The API to WebIDL2 is trivial: you parse a string of WebIDL and it returns a syntax tree.
### Parsing
In Node, that happens with:
```JS
var WebIDL2 = require("webidl2");
var tree = WebIDL2.parse("string of WebIDL");
```
In the browser:
```HTML
<script src='webidl2.js'></script>
<script>
var tree = WebIDL2.parse("string of WebIDL");
</script>
```
### Errors
When there is a syntax error in the WebIDL, it throws an exception object with the following
properties:
* `message`: the error message
* `line`: the line at which the error occurred.
* `input`: a short peek at the text at the point where the error happened
* `tokens`: the five tokens at the point of error, as understood by the tokeniser
(this is the same content as `input`, but seen from the tokeniser's point of view)
The exception also has a `toString()` method that hopefully should produce a decent
error message.
### AST (Abstract Syntax Tree)
The `parse()` method returns a tree object representing the parse tree of the IDL.
Comment and white space are not represented in the AST.
The root of this object is always an array of definitions (where definitions are
any of interfaces, dictionaries, callbacks, etc. — anything that can occur at the root
of the IDL).
### IDL Type
This structure is used in many other places (operation return types, argument types, etc.).
It captures a WebIDL type with a number of options. Types look like this and are typically
attached to a field called `idlType`:
```JS
{
"type": "attribute-type",
"generic": null,
"idlType": "unsigned short",
"nullable": false,
"union": false,
"extAttrs": [...]
}
```
Where the fields are as follows:
* `type`: String indicating where this type is used. Can be `null` if not applicable.
* `generic`: String indicating the generic type (e.g. "Promise", "sequence"). `null`
otherwise.
* `idlType`: Can be different things depending on context. In most cases, this will just
be a string with the type name. But the reason this field isn't called "typeName" is
because it can take more complex values. If the type is a union, then this contains an
array of the types it unites. If it is a generic type, it contains the IDL type
description for the type in the sequence, the eventual value of the promise, etc.
* `nullable`: Boolean indicating whether this is nullable or not.
* `union`: Boolean indicating whether this is a union type or not.
* `extAttrs`: A list of [extended attributes](#extended-attributes).
### Interface
Interfaces look like this:
```JS
{
"type": "interface",
"name": "Animal",
"partial": false,
"members": [...],
"inheritance": null,
"extAttrs": [...]
}, {
"type": "interface",
"name": "Human",
"partial": false,
"members": [...],
"inheritance": "Animal",
"extAttrs": [...]
}
```
The fields are as follows:
* `type`: Always "interface".
* `name`: The name of the interface.
* `partial`: A boolean indicating whether it's a partial interface.
* `members`: An array of interface members (attributes, operations, etc.). Empty if there are none.
* `inheritance`: A string giving the name of an interface this one inherits from, `null` otherwise.
**NOTE**: In v1 this was an array, but multiple inheritance is no longer supported so this didn't make
sense.
* `extAttrs`: A list of [extended attributes](#extended-attributes).
### Interface mixins
Interfaces mixins look like this:
```JS
{
"type": "interface mixin",
"name": "Animal",
"partial": false,
"members": [...],
"extAttrs": [...]
}, {
"type": "interface mixin",
"name": "Human",
"partial": false,
"members": [...],
"extAttrs": [...]
}
```
The fields are as follows:
* `type`: Always "interface mixin".
* `name`: The name of the interface mixin.
* `partial`: A boolean indicating whether it's a partial interface mixin.
* `members`: An array of interface members (attributes, operations, etc.). Empty if there are none.
* `extAttrs`: A list of [extended attributes](#extended-attributes).
### Namespace
Namespaces look like this:
```JS
{
"type": "namespace",
"name": "Console",
"partial": false,
"members": [...],
"extAttrs": [...]
}
```
The fields are as follows:
* `type`: Always "namespace".
* `name`: The name of the namespace.
* `partial`: A boolean indicating whether it's a partial namespace.
* `members`: An array of namespace members (attributes and operations). Empty if there are none.
* `extAttrs`: A list of [extended attributes](#extended-attributes).
### Callback Interfaces
These are captured by the same structure as [Interfaces](#interface) except that
their `type` field is "callback interface".
### Callback
A callback looks like this:
```JS
{
"type": "callback",
"name": "AsyncOperationCallback",
"idlType": {
"type": "return-type",
"sequence": false,
"generic": null,
"nullable": false,
"union": false,
"idlType": "void",
"extAttrs": []
},
"arguments": [...],
"extAttrs": []
}
```
The fields are as follows:
* `type`: Always "callback".
* `name`: The name of the callback.
* `idlType`: An [IDL Type](#idl-type) describing what the callback returns.
* `arguments`: A list of [arguments](#arguments), as in function paramters.
* `extAttrs`: A list of [extended attributes](#extended-attributes).
### Dictionary
A dictionary looks like this:
```JS
{
"type": "dictionary",
"name": "PaintOptions",
"partial": false,
"members": [{
"type": "field",
"name": "fillPattern",
"required": false,
"idlType": {
"type": "dictionary-type",
"sequence": false,
"generic": null,
"nullable": true,
"union": false,
"idlType": "DOMString",
"extAttrs": [...]
},
"extAttrs": [],
"default": {
"type": "string",
"value": "black"
}
}],
"inheritance": null,
"extAttrs": []
}
```
The fields are as follows:
* `type`: Always "dictionary".
* `name`: The dictionary name.
* `partial`: Boolean indicating whether it's a partial dictionary.
* `members`: An array of members (see below).
* `inheritance`: A string indicating which dictionary is being inherited from, `null` otherwise.
* `extAttrs`: A list of [extended attributes](#extended-attributes).
All the members are fields as follows:
* `type`: Always "field".
* `name`: The name of the field.
* `required`: Boolean indicating whether this is a [required](https://heycam.github.io/webidl/#required-dictionary-member) field.
* `idlType`: An [IDL Type](#idl-type) describing what field's type.
* `extAttrs`: A list of [extended attributes](#extended-attributes).
* `default`: A [default value](#default-and-const-values), absent if there is none.
### Enum
An enum looks like this:
```JS
{
"type": "enum",
"name": "MealType",
"values": [
{ "type": "string", "value": "rice" },
{ "type": "string", "value": "noodles" },
{ "type": "string", "value": "other" }
],
"extAttrs": []
}
```
The fields are as follows:
* `type`: Always "enum".
* `name`: The enum's name.
* `values`: An array of values.
* `extAttrs`: A list of [extended attributes](#extended-attributes).
### Typedef
A typedef looks like this:
```JS
{
"type": "typedef",
"idlType": {
"type": "typedef-type",
"sequence": true,
"generic": "sequence",
"nullable": false,
"union": false,
"idlType": {
"type": "typedef-type",
"sequence": false,
"generic": null,
"nullable": false,
"union": false,
"idlType": "Point",
"extAttrs": [...]
},
"extAttrs": [...]
},
"name": "PointSequence",
"extAttrs": []
}
```
The fields are as follows:
* `type`: Always "typedef".
* `name`: The typedef's name.
* `idlType`: An [IDL Type](#idl-type) describing what typedef's type.
* `extAttrs`: A list of [extended attributes](#extended-attributes).
### Implements
An implements definition looks like this:
```JS
{
"type": "implements",
"target": "Node",
"implements": "EventTarget",
"extAttrs": []
}
```
The fields are as follows:
* `type`: Always "implements".
* `target`: The interface that implements another.
* `implements`: The interface that is being implemented by the target.
* `extAttrs`: A list of [extended attributes](#extended-attributes).
### Includes
An includes definition looks like this:
```JS
{
"type": "includes",
"target": "Node",
"includes": "EventTarget",
"extAttrs": []
}
```
The fields are as follows:
* `type`: Always "includes".
* `target`: The interface that includes an interface mixin.
* `includes`: The interface mixin that is being included by the target.
* `extAttrs`: A list of [extended attributes](#extended-attributes).
### Operation Member
An operation looks like this:
```JS
{
"type": "operation",
"getter": false,
"setter": false,
"deleter": false,
"static": false,
"stringifier": false,
"idlType": {
"type": "return-type",
"sequence": false,
"generic": null,
"nullable": false,
"union": false,
"idlType": "void",
"extAttrs": []
},
"name": "intersection",
"arguments": [{
"optional": false,
"variadic": true,
"extAttrs": [],
"idlType": {
"type": "argument-type",
"sequence": false,
"generic": null,
"nullable": false,
"union": false,
"idlType": "long",
"extAttrs": [...]
},
"name": "ints"
}],
"extAttrs": []
}
```
The fields are as follows:
* `type`: Always "operation".
* `getter`: True if a getter operation.
* `setter`: True if a setter operation.
* `deleter`: True if a deleter operation.
* `static`: True if a static operation.
* `stringifier`: True if a stringifier operation.
* `idlType`: An [IDL Type](#idl-type) of what the operation returns. If a stringifier, may be absent.
* `name`: The name of the operation. If a stringifier, may be `null`.
* `arguments`: An array of [arguments](#arguments) for the operation.
* `extAttrs`: A list of [extended attributes](#extended-attributes).
### Attribute Member
An attribute member looks like this:
```JS
{
"type": "attribute",
"static": false,
"stringifier": false,
"inherit": false,
"readonly": false,
"idlType": {
"type": "attribute-type",
"sequence": false,
"generic": null,
"nullable": false,
"union": false,
"idlType": "RegExp",
"extAttrs": [...]
},
"name": "regexp",
"extAttrs": []
}
```
The fields are as follows:
* `type`: Always "attribute".
* `name`: The attribute's name.
* `static`: True if it's a static attribute.
* `stringifier`: True if it's a stringifier attribute.
* `inherit`: True if it's an inherit attribute.
* `readonly`: True if it's a read-only attribute.
* `idlType`: An [IDL Type](#idl-type) for the attribute.
* `extAttrs`: A list of [extended attributes](#extended-attributes).
### Constant Member
A constant member looks like this:
```JS
{
"type": "const",
"nullable": false,
"idlType": {
"type": "const-type",
"sequence": false,
"generic": null,
"nullable": false,
"union": false,
"idlType": "boolean"
"extAttrs": []
},
"name": "DEBUG",
"value": {
"type": "boolean",
"value": false
},
"extAttrs": []
}
```
The fields are as follows:
* `type`: Always "const".
* `nullable`: Whether its type is nullable.
* `idlType`: An [IDL Type](#idl-type) of the constant that represents a simple type, the type name.
* `name`: The name of the constant.
* `value`: The constant value as described by [Const Values](#default-and-const-values)
* `extAttrs`: A list of [extended attributes](#extended-attributes).
### Arguments
The arguments (e.g. for an operation) look like this:
```JS
{
"arguments": [{
"optional": false,
"variadic": true,
"extAttrs": [],
"idlType": {
"type": "argument-type",
"sequence": false,
"generic": null,
"nullable": false,
"union": false,
"idlType": "long",
"extAttrs": [...]
},
"name": "ints"
}]
}
```
The fields are as follows:
* `optional`: True if the argument is optional.
* `variadic`: True if the argument is variadic.
* `idlType`: An [IDL Type](#idl-type) describing the type of the argument.
* `name`: The argument's name.
* `extAttrs`: A list of [extended attributes](#extended-attributes).
### Extended Attributes
Extended attributes are arrays of items that look like this:
```JS
{
"extAttrs": [{
"name": "TreatNullAs",
"arguments": null,
"type": "extended-attribute",
"rhs": {
"type": "identifier",
"value": "EmptyString"
}
}]
}
```
The fields are as follows:
* `name`: The extended attribute's name.
* `arguments`: If the extended attribute takes arguments (e.g. `[Foo()]`) or if
its right-hand side does (e.g. `[NamedConstructor=Name(DOMString blah)]`) they
are listed here. Note that an empty arguments list will produce an empty array,
whereas the lack thereof will yield a `null`. If there is an `rhs` field then
they are the right-hand side's arguments, otherwise they apply to the extended
attribute directly.
* `type`: Always `"extended-attribute"`.
* `rhs`: If there is a right-hand side, this will capture its `type` (which can be
"identifier" or "identifier-list") and its `value`.
### Default and Const Values
Dictionary fields and operation arguments can take default values, and constants take
values, all of which have the following fields:
* `type`: One of string, number, boolean, null, Infinity, NaN, or sequence.
For string, number, boolean, and sequence:
* `value`: The value of the given type, as a string. For sequence, the only possible value is `[]`.
For Infinity:
* `negative`: Boolean indicating whether this is negative Infinity or not.
### `iterable<>`, `legacyiterable<>`, `maplike<>`, `setlike<>` declarations
These appear as members of interfaces that look like this:
```JS
{
"type": "maplike", // or "legacyiterable" / "iterable" / "setlike"
"idlType": /* One or two types */ ,
"readonly": false, // only for maplike and setlike
"extAttrs": []
}
```
The fields are as follows:
* `type`: Always one of "iterable", "legacyiterable", "maplike" or "setlike".
* `idlType`: An array with one or more [IDL Types](#idl-type) representing the declared type arguments.
* `readonly`: Whether the maplike or setlike is declared as read only.
* `extAttrs`: A list of [extended attributes](#extended-attributes).
## Testing
### Running
The test runs with mocha and expect.js. Normally, running mocha in the root directory
should be enough once you're set up.
### Coverage
Current test coverage, as documented in `coverage.html`, is 95%. You can run your own
coverage analysis with:
```Bash
jscoverage lib lib-cov
```
That will create the lib-cov directory with instrumented code; the test suite knows
to use that if needed. You can then run the tests with:
```Bash
JSCOV=1 mocha --reporter html-cov > coverage.html
```
Note that I've been getting weirdly overescaped results from the html-cov reporter,
so you might wish to try this instead:
```Bash
JSCOV=1 mocha --reporter html-cov | sed "s/&lt;/</g" | sed "s/&gt;/>/g" | sed "s/&quot;/\"/g" > coverage.html
```
### Browser tests
In order to test in the browser, get inside `test/web` and run `make-web-tests.js`. This
will generate a `browser-tests.html` file that you can open in a browser. As of this
writing tests pass in the latest Firefox, Chrome, Opera, and Safari. Testing on IE
and older versions will happen progressively.
-55
View File
@@ -1,55 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>WebIDL 2 Checker</title>
<script src='../lib/webidl2.js'></script>
<script>
let parserResult = undefined;
function formatParserOutput() {
const outputEl = document.getElementById('webidl-checker-output');
if (parserResult) {
const prettyPrintEl = document.getElementById('pretty-print');
outputEl.innerText = JSON.stringify(parserResult, null, prettyPrintEl.checked ? 2 : null);
} else {
outputEl.innerText = '';
}
}
function checkWebIDL(textToCheck) {
const validation = document.getElementById('webidl-checker-validation');
parserResult = null;
try {
parserResult = WebIDL2.parse(textToCheck);
validation.innerText = 'WebIDL parsed successfully!';
} catch (e) {
validation.innerText = 'Exception while parsing WebIDL. See JavaScript console for more details.\n\n' + e.toString();
// Pass it along to the JavaScript console.
throw e;
} finally {
formatParserOutput();
}
}
</script>
<style>
textarea {
font-family: monospace;
}
</style>
</head>
<body>
<h2>WebIDL Checker</h2>
<p>This is an online checker for WebIDL built on the <a href="https://github.com/w3c/webidl2.js">webidl2.js</a> project.</p>
<p>Enter your WebIDL to check below:</p>
<textarea id='webidl-to-check' rows='20' cols='80'></textarea>
<br>
<input type='button' value='Check WebIDL' onclick='checkWebIDL(document.getElementById("webidl-to-check").value)'>
<p>Validation results:</p>
<textarea id='webidl-checker-validation' rows='20' cols='80'></textarea>
<p>Parser output:</p>
<textarea id='webidl-checker-output' rows='20' cols='80'></textarea>
<br>
<input type='checkbox' id='pretty-print' checked='true' onchange='formatParserOutput()'>Pretty Print
</body>
</html>
-341
View File
@@ -1,341 +0,0 @@
<!DOCTYPE html><html><head><title>Coverage</title><script>
headings = [];
onload = function(){
headings = document.querySelectorAll('h2');
};
onscroll = function(e){
var heading = find(window.scrollY);
if (!heading) return;
var links = document.querySelectorAll('#menu a')
, link;
for (var i = 0, len = links.length; i < len; ++i) {
link = links[i];
link.className = link.getAttribute('href') == '#' + heading.id
? 'active'
: '';
}
};
function find(y) {
var i = headings.length
, heading;
while (i--) {
heading = headings[i];
if (y >= heading.offsetTop) {
return heading;
}
}
}
</script>
<style>
body {
font: 14px/1.6 "Helvetica Neue", Helvetica, Arial, sans-serif;
margin: 0;
color: #2C2C2C;
border-top: 2px solid #ddd;
}
#coverage {
padding: 60px;
}
h1 a {
color: inherit;
font-weight: inherit;
}
h1 a:hover {
text-decoration: none;
}
.onload h1 {
opacity: 1;
}
h2 {
width: 80%;
margin-top: 80px;
margin-bottom: 0;
font-weight: 100;
letter-spacing: 1px;
border-bottom: 1px solid #eee;
}
a {
color: #8A6343;
font-weight: bold;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
ul {
margin-top: 20px;
padding: 0 15px;
width: 100%;
}
ul li {
float: left;
width: 40%;
margin-top: 5px;
margin-right: 60px;
list-style: none;
border-bottom: 1px solid #eee;
padding: 5px 0;
font-size: 12px;
}
ul::after {
content: '.';
height: 0;
display: block;
visibility: hidden;
clear: both;
}
code {
font: 12px monaco, monospace;
}
pre {
margin: 30px;
padding: 30px;
border: 1px solid #eee;
border-bottom-color: #ddd;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
-webkit-box-shadow: inset 0 0 10px #eee;
-moz-box-shadow: inset 0 0 10px #eee;
overflow-x: auto;
}
img {
margin: 30px;
padding: 1px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
-webkit-box-shadow: 0 3px 10px #dedede, 0 1px 5px #888;
-moz-box-shadow: 0 3px 10px #dedede, 0 1px 5px #888;
max-width: 100%;
}
footer {
background: #eee;
width: 100%;
padding: 50px 0;
text-align: right;
border-top: 1px solid #ddd;
}
footer span {
display: block;
margin-right: 30px;
color: #888;
font-size: 12px;
}
#menu {
position: fixed;
font-size: 12px;
overflow-y: auto;
top: 0;
right: 0;
margin: 0;
height: 100%;
padding: 15px 0;
text-align: right;
border-left: 1px solid #eee;
-moz-box-shadow: 0 0 2px #888
, inset 5px 0 20px rgba(0,0,0,.5)
, inset 5px 0 3px rgba(0,0,0,.3);
-webkit-box-shadow: 0 0 2px #888
, inset 5px 0 20px rgba(0,0,0,.5)
, inset 5px 0 3px rgba(0,0,0,.3);
-webkit-font-smoothing: antialiased;
background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGYAAABmCAMAAAAOARRQAAABelBMVEUjJSU6OzshIyM5OjoqKy02NjgsLS01NTYjJCUzNTUgISMlJSc0NTUvMDA6PDwlJyg1NjYoKis2NjYrLS02ODkpKyw0NDYrLC04ODovLzA4Ojo0NDUtLy86OjwjIyU4OTosLS82ODgtLS8hIyQvMTEnKCooKSsrKy0qLCwkJSUnKCkrLCwpKiwwMjIxMzMqLC0tLS0pKissLC00NTYwMDIwMTQpKysoKSovMDEtLzA2OTkxMzUrKywvLy8qKyszNTY5OzsqKiw6OjswMDExNDUoKiozNDUvMDIyNDY1Njg2Njk5OTozMzU0NjY4ODkiIyUiIyQ4OTkuMDEmKCowMjQwMTErLS4qKywwMTMhIiMpKiopKy0tLjAkJScxNDQvLzExNDYyNDQmKCk5OTslJig5OjskJSYxMzQrLS8gISIwMTIoKCk1NTUlJSUnJygwMDA4ODgiIiMhISI8PDw6Ojo5OTkpKSojIyQ7OzsyMjIpKSssLCw6Ozw1NjlrfLakAAAg2UlEQVR42jR6i3ea6rYvPgANIAhVXh8WvkQlioUiFlFcBtAmoiRNdzxqu9p0J7vrdK29zuPeex77nnvO/35n1r1ndHRktI0jTOacv/l7lCBK5UqVpOha/YxmWK7BC4TQFKVXrbYsnimqxuuMVlOQ0XltWjUdCwRJ1M+tC1KudOs9q6+da2adUewG0SC0SwELfHtgDds93VEuydEbl3QMWeNoYkR7b/0x1ZRobGI3mLwzAhePqTAwhg6aogjNsGy7/jwQ4rkdqe7CWLxF8k9LfMVFyRS7VJqtkrW8Vt/bkR8FZJao16ipknbC3Yw2lM7laO6HBEOadEZ2tpf65c4v8e3u7FyU6qbiNNyCuzXZ6pawgnwgmrpTT/Q7w2EZmiIJ0dzWDI7mhQ80IfRnMu2kzA5r5r1pIFoia+/d93HRYp1GV8TbrkWoU/+jdI0Ff6yGwTjT1Hn8J+8m1rKpGiYPuNiHnMtNMIv+zpsk84MYTNW1/+DpwXLvckdOCMYowVNPREe0QlM8xRHXXFhcNDzupwsSmb5pH+0t0RP2Qk+QtI7F1Qm6JRC6ZPBtPq/dq/kH+jxtCljn9TIpW6rQIgmSVyj6lPICIw4N/taka41PFUInth0je9+jO6Kt1G4/a7V2LEgG02B0pHVuCZrgltSKMuIl5SyufUv9mYuQi+mFgzbBEtFo2g+Dh4sSTrLNu8JPh00sQydpb00tqXBvqRN7Q7kqzcnIxCGnvZt/WmJacoOEO6Dcn8Qre03pOCSQxbMOXUuDNx9SxuLz4W1I18gvjViQ67zV0rxdWL8Te/TQkuo8STS41DR48W7L6YP2uWIqiUV8rd6Gbf/rnegKZeG8TpAM6afhGze9JAOxbLjsnUXEbrZ9vLYd7MT32cPF5mKKxmjy7huaoD9n62GOxni3iIJwv0IzZAZjdZkUtolCNLVfYZNaquFjGszVVf+J0vrz4CawoKdHnOzb0NMH7CDBOybfYNJ4rfeMyFNjkFYVTzMFs87rnPGXLUOeNKRVc0LnU7/UIgelzsy3CMuth0YfvnY0wsD3vODUL3eJcKqHQpm8yM3XZQWJxO6Un9iYloyyLpOwN2obHy6W6gbpcb44XmyC+mg+itAcaprGcrwZCqMj/GmtKn0zPvpTz/Cv1dw21XwP3cRupg3H3MF/S71eTKj1YrdwKdc2Mw0fRmb2sFf8lW3aU6JbIZSEPqvXvjM7G/aApyXlXeqKfMq0g/Su3rUGJPSPrtGElgknrZM3xUXqsAP6zMCNVn5u8aJnSNpJv2uru7t2jfRziW2+GuhqfldUNbPk71olwo+46ePUo1U3WKk/e5YK07F/wGRgcpODmQnIlVeHCWBE4puBi2jq28UKpqiN1/4UOrGz59TNYrrQHtd+11sG40BGD+pXdelNqGOg4NXe8W4eacJV/NS9/2Umtym6WQqveqR9xdCMElpxnbkalM4Vf9uaEcWZaKdyibEIjWKxJZPN95niCL3GiaXyssIrHxoLkqkzLCXULN46/f2h3tQJgyip+Tk9EAjJ9aJshq7t8X45aowSKspMSvPf7r9R8yxNptIaHS5ozuEm6luPDApugyNP8OaqiQ4BjaequXA54SLC83eHIY2r+CZp4409Xqw8Aa2oI7XkCrQi+in0w5AqF/kLNrcUz+qkl/lAobY1jSnx5OJNhyXIz3qfNFlXc0TKaglNwdWkWYt9QQ1Kr6W8zue21iNrdJk+N5oCr2O9nEtWKC7IS5J/zdDEYrmnAYfg6agCy+qcgz7ZofeDc4PbUWSvkshWuAc7OjiUyLkj+RAtdlwXJcjxdpkTTHDhK8lBCi8+JtvDVL1W6elmOM++YS0LuSlaP1oUvAeiW3cFnvTr8EbTz1tsSMYdGeZe40sRWu5uAfj7q+ZoKv2FNQ0p5XY1lmlcigHZqTPpabufEVrNuNPi165w3uCVQJHyJqmSJ7ZHnguqwtCmwViIJijj04ba2JNYtB+yORf5gg1/9t9iw4vUpeqiunSAbf+IBdj/b+iG2qrHvuNP0Vd/+ThVZT/lrvHYjjgDbbyxaqgHNM2uhxa1GW3UedZYhMMwM4mQhltouK+IV4NdbIQNM+8Yv311RZk9kT4tiYR4LkyFcuPpdcjuhUuFqBAWRZa11lcZ3gEBlXywsNhrt+plISZP5DlsV9l4EgY6J3yZPTUcMrgaWAT3oI79eSbGEbcJpr6BD8kyDiVt+G0/hXosQN4NFXKlfWIfsIs0BHODVok1/IGnKFHJYIquh8Xo+2+bkQNTGgWmN/fZ0Y33LSj6lr1GyV7mWIKg7ZTRZPGuhF/zjRNcQ1UPtSYgnWQxSs0yrVhwNDcdGMNSNe2JT3WuzbAM3HykyAajS3Uphf6STKEqxLas9EnmnhA/lyj9Uj+JoY7SVgVmGLl46Rm2u98sbkap2lzAdKBG4r6LgulQOSSjQv1GWdQ0jtDUK/mAaqM1Uqjpu4k3Rvfvxv7YTxLSK+wN3E5jVIzmF23uZ7hiH/sVP49D7tvoKp4S8b1LuvRlivVB/algbhcFITYVXvDpLzpDfplR2uD5V4XJFxpjmIpLc9Y5sB2TpBRix7Bme6GZIq+06v3XzNeTcA4obQIKxrnT4C2JpOqD92dbmSX8MGazly5EsZVMvSU1f4RZwyu8iQXbVdeLlZrjuTT1jrY1uk5c7iZ7RsvhhluqAkq4JpVQAg7RJFtSu+xgJ8Pv6O1j5DkLxT8mkbfyRW5DrQmG7hiDIjCgBsADbjuof6YHLGeV6a5Q1Smx9joUXPpdaaDx97A/Wq00oJkdR7ZYuQRfS533JtxO1erduqWOYIt3wh0wpbLuCNIYkwxbswbikCUu2CDCS+Q+7rgVtfRcm+SOcdKPRlZ/rE7wNVUEE39KTS5uvUKN1PUnkloPkyzhyGQ8qkouEjJ3H/VXdqG6asSRiw3ecMlBvDDt8dDhBHXMwZ2Cajzjr7/76T+IavqPYvz6r7//E/3X3+N//h/0QozbjPgPiir69P/8X3/9F/yv8b/827/++98WItPu5/Hvwd8YPf5bp/2/lX/T/+Of/0MJ/lYTa+L/Ef+d9vN/3/2T6P/+jyTzu/evf6U7vxN7B6pJkRtAF6jUr8I+P8RsP/ptGhfqFk+pQ/DgAy6NJtRYJdXmp4gK7WLqLKJ+MaKhGjOojvL+SnIWrkpy0SLHDe4QuyNzaEA15mLMCcmE8Em+4HdOihW4/ZWuppJEmzeAwcDtv7MuLc9y2V5atvxXNe3S4DUMt5/Qy2LM9kSYKiVWBuKlfp4nxTntpuW03JbIlkiRvBXmT23g1I2OYe6IizUHPIq6zm6mbfsbteKmi/sg9J+ocQBMctGFO7iljo8TPN+z3jxw4do+ZwfqoR9dkNTKHyM305GpTkfhcHexVkPVGEbUOjuo9f0UMPHBFlGEx0SLvJvVRKTwW7PSew5oPme+E42+frJa9cGt2njS3dK5kIif2eYbhuSEQXEqMVfUjhGIuin0G0/W5ezJyJQy3SpMLai4M0JUWb5u1k9tny5bd1pPwYBpQuDCXZl62xg4CdVEAtflXHs6JKmP/pH6mOl796Lgopj0o8d5kKh00hxG3OSdEE/QBo9Hgr8JJqAeLDwJohG5j/DGh61Rc/+tf22/8kEnxHNCEjo0ElvvGfESZkqmz2BDcKV1H1buSkhkdg7p1IMGs2s17nYjpblrWuE2K9WEO/hcRp5e9oOF/QBmOaDtgil+oaU6szPrdwW65fOB0KUTsVUn7LFU7J8e6cxJIl9+FHw5MQMzuQJ+4oxMH3iW/5GK+hWuG0T+gTLs+fAjdtUd58TmIUq04EeyRCYCjkldow234aIgR5bqwrtZosZ+6YEqAmDqatJ9lWasz4IquKALPtd92hGI3Z2BdzzZue+REl1Om4DIWD+RrtUTOJLI+S0jHowXXdAxsGLSd40zYNuEUlOGhrwL6c7tcOtUOvpJCP7QBQS19H+GvZn05ewjlVLz+IGKoC9TyfQjLMBNmXCuqqtTdOSukZW48B0HqgSTCBrBnlFvF4CG2Su7yFzqmJFURK3UmTT3ru050r0ptUpMilYnBJWfl2Bv6kPlUuE1kxxpdzui9AubsR2N2boVSu81OulAwBqoSr1LZ0LLYOomyZHmjqnXlP72s8LnDouEJjtodBvdHaG1jMySYO7crWd90MpCRyCG14vb5IE7Arupw/y/RcCm/Tm3zK6zYj8PYNaGldiUfkB/LHWcmf2lVM+mwyU27a0qq2tscrQ/vzBjN26DnntIrOyGizzXK35yKQdYnUABkyN4saz3WD/viF+eCcsXnIajdWYJWaYHRstIis9CS+tqnFGmz2j5uzfr3Z4prqgK4XOT/PyftvjZqIm8lhkfxJ7Ol3CJF1piYBGAG8wtAkLine truncated
}
#menu::after {
display: block;
content: '';
padding-top: 80px;
}
#logo {
position: fixed;
bottom: 10px;
right: 10px;
background: rgba(255,255,255,.1);
font-size: 11px;
display: block;
width: 20px;
height: 20px;
line-height: 20px;
text-align: center;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
-webkit-box-shadow: 0 0 3px rgba(0,0,0,.2);
-moz-box-shadow: 0 0 3px rgba(0,0,0,.2);
color: inherit;
}
#menu li a {
display: block;
color: white;
padding: 0 35px 0 25px;
-webkit-transition: background 300ms;
-moz-transition: background 300ms;
}
#menu li {
position: relative;
list-style: none;
}
#menu a:hover,
#menu a.active {
text-decoration: none;
background: rgba(255,255,255,.1);
}
#menu li:hover .cov {
opacity: 1;
}
#menu li .dirname {
opacity: .60;
padding-right: 2px;
}
#menu li .basename {
opacity: 1;
}
#menu .cov {
background: rgba(0,0,0,.4);
position: absolute;
top: 0;
right: 8px;
font-size: 9px;
opacity: .6;
text-align: left;
width: 17px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
padding: 2px 3px;
text-align: center;
}
#stats:nth-child(2n) {
display: inline-block;
margin-top: 15px;
border: 1px solid #eee;
padding: 10px;
-webkit-box-shadow: inset 0 0 2px #eee;
-moz-box-shadow: inset 0 0 2px #eee;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
}
#stats div {
float: left;
padding: 0 5px;
}
#stats::after {
display: block;
content: '';
clear: both;
}
#stats .sloc::after {
content: ' SLOC';
color: #b6b6b6;
}
#stats .percentage::after {
content: ' coverage';
color: #b6b6b6;
}
#stats .hits,
#stats .misses {
display: none;
}
.high {
color: #00d4b4;
}
.medium {
color: #e87d0d;
}
.low {
color: #d4081a;
}
.terrible {
color: #d4081a;
font-weight: bold;
}
table {
width: 80%;
margin-top: 10px;
border-collapse: collapse;
border: 1px solid #cbcbcb;
color: #363636;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
}
table thead {
display: none;
}
table td.line,
table td.hits {
width: 20px;
background: #eaeaea;
text-align: center;
font-size: 11px;
padding: 0 10px;
color: #949494;
}
table td.hits {
width: 10px;
padding: 2px 5px;
color: rgba(0,0,0,.2);
background: #f0f0f0;
}
tr.miss td.line,
tr.miss td.hits {
background: #e6c3c7;
}
tr.miss td {
background: #f8d5d8;
}
td.source {
padding-left: 15px;
line-height: 15px;
white-space: pre;
font: 12px monaco, monospace;
}
code .comment { color: #ddd }
code .init { color: #2F6FAD }
code .string { color: #5890AD }
code .keyword { color: #8A6343 }
code .number { color: #2F6FAD }
</style></head><body><div id="coverage"><h1 id="overview">Coverage</h1><div id="menu"><li><a href="#overview">overview</a></li><li><span class="cov high">95</span><a href="#webidl2.js"><span class="basename">webidl2.js</span></a></li><a id="logo" href="http://visionmedia.github.com/mocha/">m</a></div><div id="stats" class="high"><div class="percentage">95%</div><div class="sloc">572</div><div class="hits">548</div><div class="misses">24</div></div><div id="files"><div class="file"><h2 id="webidl2.js">webidl2.js</h2><div id="stats" class="high"><div class="percentage">95%</div><div class="sloc">572</div><div class="hits">548</div><div class="misses">24</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr><td class="line">1</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">2</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">3</td><td class="hits">1</td><td class="source"><span class="k">(</span><span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">4</td><td class="hits">1</td><td class="source"> <span class="k">var</span> tokenise <span class="k">=</span> <span class="k">function</span> <span class="k">(</span>str<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">5</td><td class="hits">47</td><td class="source"> <span class="k">var</span> tokens <span class="k">=</span> <span class="k">[]</span></td></tr><tr><td class="line">6</td><td class="hits"></td><td class="source"> <span class="k">,</span> re <span class="k">=</span> <span class="k">{</span></td></tr><tr><td class="line">7</td><td class="hits"></td><td class="source"> <span class="s">"float"</span><span class="k">:</span> <span class="s">/^-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)/</span></td></tr><tr><td class="line">8</td><td class="hits"></td><td class="source"> <span class="k">,</span> <span class="s">"integer"</span><span class="k">:</span> <span class="s">/^-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/</span></td></tr><tr><td class="line">9</td><td class="hits"></td><td class="source"> <span class="k">,</span> <span class="s">"identifier"</span><span class="k">:</span> <span class="s">/^[A-Z_a-z][0-9A-Z_a-z]*/</span></td></tr><tr><td class="line">10</td><td class="hits"></td><td class="source"> <span class="k">,</span> <span class="s">"string"</span><span class="k">:</span> <span class="s">/^"[^"]*"/</span></td></tr><tr><td class="line">11</td><td class="hits"></td><td class="source"> <span class="k">,</span> <span class="s">"whitespace"</span><span class="k">:</span> <span class="s">/^(?:[\t\n\r ]+|[\t\n\r ]*((\/\/.*|\/\*(.|\n|\r)*?\*\/)[\t\n\r ]*))+/</span></td></tr><tr><td class="line">12</td><td class="hits"></td><td class="source"> <span class="k">,</span> <span class="s">"other"</span><span class="k">:</span> <span class="s">/^[^\t\n\r 0-9A-Z_a-z]/</span></td></tr><tr><td class="line">13</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">14</td><td class="hits"></td><td class="source"> <span class="k">,</span> types <span class="k">=</span> <span class="k">[]</span></td></tr><tr><td class="line">15</td><td class="hits"></td><td class="source"> <span class="k">;</span></td></tr><tr class="hit"> <td class="line">16</td><td class="hits">329</td><td class="source"> <span class="k">for</span> <span class="k">(</span><span class="k">var</span> k <span class="k">in</span> re<span class="k">)</span> types<span class="k">.</span>push<span class="k">(</span>k<span class="k">);</span></td></tr><tr class="hit"> <td class="line">17</td><td class="hits">47</td><td class="source"> <span class="k">while</span> <span class="k">(</span>str<span class="k">.</span>length <span class="k">></span> <span class="s">0</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">18</td><td class="hits">2914</td><td class="source"> <span class="k">var</span> matched <span class="k">=</span> <span class="k">false</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">19</td><td class="hits">2914</td><td class="source"> <span class="k">for</span> <span class="k">(</span><span class="k">var</span> i <span class="k">=</span> <span class="s">0</span><span class="k">,</span> n <span class="k">=</span> types<span class="k">.</span>length<span class="k">;</span> i <span class="k"><</span> n<span class="k">;</span> i<span class="k">++)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">20</td><td class="hits">13325</td><td class="source"> <span class="k">var</span> type <span class="Line truncated
-1
View File
@@ -1 +0,0 @@
module.exports = require("./lib/webidl2.js");
-221
View File
@@ -1,221 +0,0 @@
"use strict";
(() => {
function write(ast, opt = {}) {
const noop = str => str;
const optNames = "type".split(" ");
const context = [];
for (const o of optNames) {
if (!opt[o]) opt[o] = noop;
}
function literal(it) {
return it.value;
};
function type(it) {
if (typeof it === "string") return opt.type(it); // XXX should maintain some context
let ret = extended_attributes(it.extAttrs);
if (it.union) ret += `(${it.idlType.map(type).join(" or ")})`;
else {
if (it.generic) ret += `${it.generic}<`;
if (Array.isArray(it.idlType)) ret += it.idlType.map(type).join(", ");
else ret += type(it.idlType);
if (it.generic) ret += ">";
}
if (it.nullable) ret += "?";
return ret;
};
function const_value(it) {
const tp = it.type;
if (tp === "boolean") return it.value ? "true" : "false";
else if (tp === "null") return "null";
else if (tp === "Infinity") return (it.negative ? "-" : "") + "Infinity";
else if (tp === "NaN") return "NaN";
else if (tp === "number") return it.value;
else if (tp === "sequence") return "[]";
else return `"${it.value}"`;
};
function argument(arg) {
let ret = extended_attributes(arg.extAttrs);
if (arg.optional) ret += "optional ";
ret += type(arg.idlType);
if (arg.variadic) ret += "...";
ret += ` ${arg.escapedName}`;
if (arg.default) ret += ` = ${const_value(arg.default)}`;
return ret;
};
function make_ext_at(it) {
context.unshift(it);
let ret = it.name;
if (it.rhs) {
if (it.rhs.type === "identifier-list") ret += `=(${it.rhs.value.join(",")})`;
else ret += `=${it.rhs.value}`;
}
if (it.arguments) ret += `(${it.arguments.length ? it.arguments.map(argument).join(",") : ""})`;
context.shift(); // XXX need to add more contexts, but not more than needed for ReSpec
return ret;
};
function extended_attributes(eats) {
if (!eats || !eats.length) return "";
return `[${eats.map(make_ext_at).join(", ")}]`;
};
const modifiers = "getter setter deleter stringifier static".split(" ");
function operation(it) {
let ret = extended_attributes(it.extAttrs);
if (it.stringifier && !it.idlType) return "stringifier;";
for (const mod of modifiers) {
if (it[mod]) ret += mod + " ";
}
ret += type(it.idlType) + " ";
if (it.name) ret += it.escapedName;
ret += `(${it.arguments.map(argument).join(",")});`;
return ret;
};
function attribute(it) {
let ret = extended_attributes(it.extAttrs);
if (it.static) ret += "static ";
if (it.stringifier) ret += "stringifier ";
if (it.inherit) ret += "inherit ";
if (it.readonly) ret += "readonly ";
ret += `attribute ${type(it.idlType)} ${it.escapedName};`;
return ret;
};
function interface_(it) {
let ret = extended_attributes(it.extAttrs);
if (it.partial) ret += "partial ";
ret += `interface ${it.name} `;
if (it.inheritance) ret += `: ${it.inheritance} `;
ret += `{${iterate(it.members)}};`;
return ret;
};
function interface_mixin(it) {
let ret = extended_attributes(it.extAttrs);
if (it.partial) ret += "partial ";
ret += `interface mixin ${it.name} `;
ret += `{${iterate(it.members)}};`;
return ret;
}
function namespace(it) {
let ret = extended_attributes(it.extAttrs);
if (it.partial) ret += "partial ";
ret += `namespace ${it.name} `;
ret += `{${iterate(it.members)}};`;
return ret;
}
function dictionary(it) {
let ret = extended_attributes(it.extAttrs);
if (it.partial) ret += "partial ";
ret += `dictionary ${it.name} `;
if (it.inheritance) ret += `: ${it.inheritance} `;
ret += `{${iterate(it.members)}};`;
return ret;
};
function field(it) {
let ret = extended_attributes(it.extAttrs);
if (it.required) ret += "required ";
ret += `${type(it.idlType)} ${it.escapedName}`;
if (it.default) ret += ` = ${const_value(it.default)}`;
ret += ";";
return ret;
};
function const_(it) {
const ret = extended_attributes(it.extAttrs);
return `${ret}const ${type(it.idlType)}${it.nullable ? "?" : ""} ${it.name} = ${const_value(it.value)};`;
};
function typedef(it) {
let ret = extended_attributes(it.extAttrs);
ret += `typedef ${extended_attributes(it.typeExtAttrs)}`;
return `${ret}${type(it.idlType)} ${it.name};`;
};
function implements_(it) {
const ret = extended_attributes(it.extAttrs);
return `${ret}${it.target} implements ${it.implements};`;
};
function includes(it) {
const ret = extended_attributes(it.extAttrs);
return `${ret}${it.target} includes ${it.includes};`;
};
function callback(it) {
const ret = extended_attributes(it.extAttrs);
return `${ret}callback ${it.name} = ${type(it.idlType)}(${it.arguments.map(argument).join(",")});`;
};
function enum_(it) {
let ret = extended_attributes(it.extAttrs);
ret += `enum ${it.name} {`;
for (const v of it.values) {
ret += `"${v.value}",`;
}
return ret + "};";
};
function iterable(it) {
return `iterable<${Array.isArray(it.idlType) ? it.idlType.map(type).join(", ") : type(it.idlType)}>;`;
};
function legacyiterable(it) {
return `legacyiterable<${Array.isArray(it.idlType) ? it.idlType.map(type).join(", ") : type(it.idlType)}>;`;
};
function maplike(it) {
return `${it.readonly ? "readonly " : ""}maplike<${it.idlType.map(type).join(", ")}>;`;
};
function setlike(it) {
return `${it.readonly ? "readonly " : ""}setlike<${type(it.idlType[0])}>;`;
};
function callbackInterface(it) {
return `callback ${interface_(it)}`;
};
const table = {
interface: interface_,
"interface mixin": interface_mixin,
namespace,
operation,
attribute,
dictionary,
field,
const: const_,
typedef,
implements: implements_,
includes,
callback,
enum: enum_,
iterable,
legacyiterable,
maplike,
setlike,
"callback interface": callbackInterface
};
function dispatch(it) {
const dispatcher = table[it.type];
if (!dispatcher) {
throw new Error(`Type "${it.type}" is unsupported`)
}
return table[it.type](it);
};
function iterate(things) {
if (!things) return;
let ret = "";
for (const thing of things) ret += dispatch(thing);
return ret;
};
return iterate(ast);
};
const obj = {
write
};
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = obj;
} else if (typeof define === 'function' && define.amd) {
define([], () => obj);
} else {
(self || window).WebIDL2Writer = obj;
}
})();
-700
View File
@@ -1,700 +0,0 @@
{
"name": "webidl2",
"version": "13.0.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@babel/code-frame": {
"version": "7.0.0-beta.40",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.40.tgz",
"integrity": "sha512-eVXQSbu/RimU6OKcK2/gDJVTFcxXJI4sHbIqw2mhwMZeQ2as/8AhS9DGkEDoHMBBNJZ5B0US63lF56x+KDcxiA==",
"dev": true,
"requires": {
"@babel/highlight": "7.0.0-beta.40"
}
},
"@babel/highlight": {
"version": "7.0.0-beta.40",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.40.tgz",
"integrity": "sha512-mOhhTrzieV6VO7odgzFGFapiwRK0ei8RZRhfzHhb6cpX3QM8XXuCLXWjN8qBB7JReDdUR80V3LFfFrGUYevhNg==",
"dev": true,
"requires": {
"chalk": "^2.0.0",
"esutils": "^2.0.2",
"js-tokens": "^3.0.0"
}
},
"ansi-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
"dev": true
},
"ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"requires": {
"color-convert": "^1.9.0"
}
},
"arr-diff": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz",
"integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=",
"dev": true,
"requires": {
"arr-flatten": "^1.0.1"
}
},
"arr-flatten": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz",
"integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==",
"dev": true
},
"array-unique": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz",
"integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=",
"dev": true
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"braces": {
"version": "1.8.5",
"resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz",
"integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=",
"dev": true,
"requires": {
"expand-range": "^1.8.1",
"preserve": "^0.2.0",
"repeat-element": "^1.1.2"
}
},
"browser-stdout": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz",
"integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==",
"dev": true
},
"chalk": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.2.tgz",
"integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==",
"dev": true,
"requires": {
"ansi-styles": "^3.2.1",
"escape-string-regexp": "^1.0.5",
"supports-color": "^5.3.0"
}
},
"color-convert": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz",
"integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==",
"dev": true,
"requires": {
"color-name": "^1.1.1"
}
},
"color-name": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
"dev": true
},
"commander": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
"integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==",
"dev": true
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"dev": true,
"requires": {
"ms": "2.0.0"
}
},
"diff": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz",
"integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==",
"dev": true
},
"diff-match-patch": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/diff-match-patch/-/diff-match-patch-1.0.0.tgz",
"integrity": "sha1-HMPIOkkNZ/ldkeOfatHy4Ia2MEg=",
"dev": true
},
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
"dev": true
},
"esutils": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
"integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=",
"dev": true
},
"expand-brackets": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz",
"integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=",
"dev": true,
"requires": {
"is-posix-bracket": "^0.1.0"
}
},
"expand-range": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz",
"integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=",
"dev": true,
"requires": {
"fill-range": "^2.1.0"
}
},
"expect": {
"version": "22.4.0",
"resolved": "https://registry.npmjs.org/expect/-/expect-22.4.0.tgz",
"integrity": "sha512-Fiy862jT3qc70hwIHwwCBNISmaqBrfWKKrtqyMJ6iwZr+6KXtcnHojZFtd63TPRvRl8EQTJ+YXYy2lK6/6u+Hw==",
"dev": true,
"requires": {
"ansi-styles": "^3.2.0",
"jest-diff": "^22.4.0",
"jest-get-type": "^22.1.0",
"jest-matcher-utils": "^22.4.0",
"jest-message-util": "^22.4.0",
"jest-regex-util": "^22.1.0"
}
},
"extglob": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz",
"integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=",
"dev": true,
"requires": {
"is-extglob": "^1.0.0"
}
},
"filename-regex": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz",
"integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=",
"dev": true
},
"fill-range": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.4.tgz",
"integrity": "sha512-cnrcCbj01+j2gTG921VZPnHbjmdAf8oQV/iGeV2kZxGSyfYjjTyY79ErsK1WJWMpw6DaApEX72binqJE+/d+5Q==",
"dev": true,
"requires": {
"is-number": "^2.1.0",
"isobject": "^2.0.0",
"randomatic": "^3.0.0",
"repeat-element": "^1.1.2",
"repeat-string": "^1.5.2"
}
},
"for-in": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
"integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=",
"dev": true
},
"for-own": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz",
"integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=",
"dev": true,
"requires": {
"for-in": "^1.0.1"
}
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"dev": true
},
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"glob-base": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz",
"integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=",
"dev": true,
"requires": {
"glob-parent": "^2.0.0",
"is-glob": "^2.0.0"
}
},
"glob-parent": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz",
"integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=",
"dev": true,
"requires": {
"is-glob": "^2.0.0"
}
},
"growl": {
"version": "1.10.3",
"resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz",
"integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==",
"dev": true
},
"has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
"dev": true
},
"he": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
"integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=",
"dev": true
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"dev": true,
"requires": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
"dev": true
},
"is-buffer": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
"dev": true
},
"is-dotfile": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz",
"integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=",
"dev": true
},
"is-equal-shallow": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz",
"integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=",
"dev": true,
"requires": {
"is-primitive": "^2.0.0"
}
},
"is-extendable": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
"integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=",
"dev": true
},
"is-extglob": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz",
"integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=",
"dev": true
},
"is-glob": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz",
"integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=",
"dev": true,
"requires": {
"is-extglob": "^1.0.0"
}
},
"is-number": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz",
"integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=",
"dev": true,
"requires": {
"kind-of": "^3.0.2"
}
},
"is-posix-bracket": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz",
"integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=",
"dev": true
},
"is-primitive": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz",
"integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=",
"dev": true
},
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
"dev": true
},
"isobject": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz",
"integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=",
"dev": true,
"requires": {
"isarray": "1.0.0"
}
},
"jest-diff": {
"version": "22.4.0",
"resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-22.4.0.tgz",
"integrity": "sha512-+/t20WmnkOkB8MOaGaPziI8zWKxquMvYw4Ub+wOzi7AUhmpFXz43buWSxVoZo4J5RnCozpGbX3/FssjJ5KV9Nw==",
"dev": true,
"requires": {
"chalk": "^2.0.1",
"diff": "^3.2.0",
"jest-get-type": "^22.1.0",
"pretty-format": "^22.4.0"
}
},
"jest-get-type": {
"version": "22.1.0",
"resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-22.1.0.tgz",
"integrity": "sha512-nD97IVOlNP6fjIN5i7j5XRH+hFsHL7VlauBbzRvueaaUe70uohrkz7pL/N8lx/IAwZRTJ//wOdVgh85OgM7g3w==",
"dev": true
},
"jest-matcher-utils": {
"version": "22.4.0",
"resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-22.4.0.tgz",
"integrity": "sha512-03m3issxUXpWMwDYTfmL8hRNewUB0yCRTeXPm+eq058rZxLHD9f5NtSSO98CWHqe4UyISIxd9Ao9iDVjHWd2qg==",
"dev": true,
"requires": {
"chalk": "^2.0.1",
"jest-get-type": "^22.1.0",
"pretty-format": "^22.4.0"
}
},
"jest-message-util": {
"version": "22.4.0",
"resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-22.4.0.tgz",
"integrity": "sha512-eyCJB0T3hrlpFF2FqQoIB093OulP+1qvATQmD3IOgJgMGqPL6eYw8TbC5P/VCWPqKhGL51xvjIIhow5eZ2wHFw==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0-beta.35",
"chalk": "^2.0.1",
"micromatch": "^2.3.11",
"slash": "^1.0.0",
"stack-utils": "^1.0.1"
}
},
"jest-regex-util": {
"version": "22.1.0",
"resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-22.1.0.tgz",
"integrity": "sha512-on0LqVS6Xeh69sw3d1RukVnur+lVOl3zkmb0Q54FHj9wHoq6dbtWqb3TSlnVUyx36hqjJhjgs/QLqs07Bzu72Q==",
"dev": true
},
"js-tokens": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
"integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=",
"dev": true
},
"jsondiffpatch": {
"version": "0.3.5",
"resolved": "https://registry.npmjs.org/jsondiffpatch/-/jsondiffpatch-0.3.5.tgz",
"integrity": "sha512-v7eaGLDMCHXH+fsIaZhptEUJmS8EJpunq7IM4cc4vIT/kSRAkaZ6ZF4ebiNcyUelL0znbvj6o2B5Gh9v7Og0BQ==",
"dev": true,
"requires": {
"chalk": "^2.3.0",
"diff-match-patch": "^1.0.0"
}
},
"kind-of": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
"dev": true,
"requires": {
"is-buffer": "^1.1.5"
}
},
"math-random": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.1.tgz",
"integrity": "sha1-izqsWIuKZuSXXjzepn97sylgH6w=",
"dev": true
},
"micromatch": {
"version": "2.3.11",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz",
"integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=",
"dev": true,
"requires": {
"arr-diff": "^2.0.0",
"array-unique": "^0.2.1",
"braces": "^1.8.2",
"expand-brackets": "^0.1.4",
"extglob": "^0.3.1",
"filename-regex": "^2.0.0",
"is-extglob": "^1.0.0",
"is-glob": "^2.0.1",
"kind-of": "^3.0.2",
"normalize-path": "^2.0.1",
"object.omit": "^2.0.0",
"parse-glob": "^3.0.4",
"regex-cache": "^0.4.2"
}
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"dev": true
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true,
"requires": {
"minimist": "0.0.8"
}
},
"mocha": {
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.4.tgz",
"integrity": "sha512-nMOpAPFosU1B4Ix1jdhx5e3q7XO55ic5a8cgYvW27CequcEY+BabS0kUVL1Cw1V5PuVHZWeNRWFLmEPexo79VA==",
"dev": true,
"requires": {
"browser-stdout": "1.3.1",
"commander": "2.11.0",
"debug": "3.1.0",
"diff": "3.5.0",
"escape-string-regexp": "1.0.5",
"glob": "7.1.2",
"growl": "1.10.3",
"he": "1.1.1",
"mkdirp": "0.5.1",
"supports-color": "4.4.0"
},
"dependencies": {
"has-flag": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=",
"dev": true
},
"supports-color": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz",
"integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==",
"dev": true,
"requires": {
"has-flag": "^2.0.0"
}
}
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
"dev": true
},
"normalize-path": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
"integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=",
"dev": true,
"requires": {
"remove-trailing-separator": "^1.0.1"
}
},
"object.omit": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz",
"integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=",
"dev": true,
"requires": {
"for-own": "^0.1.4",
"is-extendable": "^0.1.1"
}
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true,
"requires": {
"wrappy": "1"
}
},
"parse-glob": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz",
"integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=",
"dev": true,
"requires": {
"glob-base": "^0.3.0",
"is-dotfile": "^1.0.0",
"is-extglob": "^1.0.0",
"is-glob": "^2.0.0"
}
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true
},
"preserve": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz",
"integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=",
"dev": true
},
"pretty-format": {
"version": "22.4.0",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-22.4.0.tgz",
"integrity": "sha512-pvCxP2iODIIk9adXlo4S3GRj0BrJiil68kByAa1PrgG97c1tClh9dLMgp3Z6cHFZrclaABt0UH8PIhwHuFLqYA==",
"dev": true,
"requires": {
"ansi-regex": "^3.0.0",
"ansi-styles": "^3.2.0"
}
},
"randomatic": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/randomatic/-/randomatic-3.0.0.tgz",
"integrity": "sha512-VdxFOIEY3mNO5PtSRkkle/hPJDHvQhK21oa73K4yAc9qmp6N429gAyF1gZMOTMeS0/AYzaV/2Trcef+NaIonSA==",
"dev": true,
"requires": {
"is-number": "^4.0.0",
"kind-of": "^6.0.0",
"math-random": "^1.0.1"
},
"dependencies": {
"is-number": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz",
"integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==",
"dev": true
},
"kind-of": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
"integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==",
"dev": true
}
}
},
"regex-cache": {
"version": "0.4.4",
"resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz",
"integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==",
"dev": true,
"requires": {
"is-equal-shallow": "^0.1.3"
}
},
"remove-trailing-separator": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
"integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=",
"dev": true
},
"repeat-element": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz",
"integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=",
"dev": true
},
"repeat-string": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
"integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=",
"dev": true
},
"slash": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz",
"integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=",
"dev": true
},
"stack-utils": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-1.0.1.tgz",
"integrity": "sha1-1PM6tU6OOHeLDKXP07OvsS22hiA=",
"dev": true
},
"supports-color": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz",
"integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==",
"dev": true,
"requires": {
"has-flag": "^3.0.0"
}
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
}
}
}
-27
View File
@@ -1,27 +0,0 @@
{
"name": "webidl2",
"description": "A WebIDL Parser",
"version": "13.0.3",
"contributors": [
"Robin Berjon <robin@berjon.com> (https://berjon.com)",
"Marcos Caceres <marcos@marcosc.com> (https://marcosc.com)",
"Kagami Sascha Rosylight <saschaplas@outlook.com>",
"Timothy Gu <timothygu99@gmail.com>"
],
"license": "W3C",
"dependencies": {},
"devDependencies": {
"expect": "22.4.0",
"jsondiffpatch": "0.3.5",
"mocha": "5.0.4"
},
"scripts": {
"test": "mocha",
"acquire": "node test/util/acquire.js"
},
"repository": "git://github.com/w3c/webidl2.js",
"main": "index.js",
"files": [
"lib/*"
]
}
@@ -1,3 +1,5 @@
// META: global=window,worker
promise_test(async t => {
const error = new Error('cannot proceed');
const rs = new ReadableStream({
@@ -5,7 +7,7 @@ promise_test(async t => {
pull: t.step_func((controller) => {
const buffer = controller.byobRequest.view.buffer;
// Detach the buffer.
postMessage(buffer, '*', [buffer]);
structuredClone(buffer, { transfer: [buffer] });
// Try to enqueue with a new buffer.
assert_throws_js(TypeError, () => controller.enqueue(new Uint8Array([42])));
@@ -1,5 +1,6 @@
// META: global=window,worker
// META: script=../resources/test-utils.js
// META: script=/common/gc.js
'use strict';
promise_test(async () => {
-20
View File
@@ -47,26 +47,6 @@ self.constructorThrowsForAll = (constructor, firstArgs) => {
'constructor should throw a TypeError'));
};
self.garbageCollect = async () => {
if (self.TestUtils?.gc) {
// https://testutils.spec.whatwg.org/#the-testutils-namespace
await TestUtils.gc();
} else if (self.gc) {
// Use --expose_gc for V8 (and Node.js)
// to pass this flag at chrome launch use: --js-flags="--expose-gc"
// Exposed in SpiderMonkey shell as well
self.gc();
} else if (self.GCController) {
// Present in some WebKit development environments
GCController.collect();
} else {
/* eslint-disable no-console */
console.warn('Tests are running without the ability to do manual garbage collection. They will still work, but ' +
'coverage will be suboptimal.');
/* eslint-enable no-console */
}
};
self.delay = ms => new Promise(resolve => step_timeout(resolve, ms));
// For tests which verify that the implementation doesn't do something it shouldn't, it's better not to use a
+17
View File
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html class="test-wait">
<script src="/common/gc.js"></script>
<script type="module">
const b = new ReadableStream({
start(c) {
c.enqueue({}) // the value we will transfer
},
})
const transferred = structuredClone(b, { transfer: [b] })
// Here we request a read, triggering a message transfer
transferred.getReader().read()
// And immediately trigger GC without waiting for the read,
// causing the actual transfer to be done after GC
await garbageCollect()
document.documentElement.classList.remove("test-wait")
</script>
-44
View File
@@ -1,44 +0,0 @@
<!doctype html>
<meta charset=utf-8>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
function bURL(url, base) {
return new URL(url, base || "about:blank")
}
function runURLTests(urltests) {
for(var i = 0, l = urltests.length; i < l; i++) {
var expected = urltests[i]
if (typeof expected === "string") continue // skip comments
test(function() {
if (expected.failure) {
assert_throws_js(TypeError, function() {
bURL(expected.input, expected.base)
})
return
}
var url = bURL(expected.input, expected.base)
assert_equals(url.href, expected.href, "href")
assert_equals(url.protocol, expected.protocol, "protocol")
assert_equals(url.username, expected.username, "username")
assert_equals(url.password, expected.password, "password")
assert_equals(url.host, expected.host, "host")
assert_equals(url.hostname, expected.hostname, "hostname")
assert_equals(url.port, expected.port, "port")
assert_equals(url.pathname, expected.pathname, "pathname")
assert_equals(url.search, expected.search, "search")
if ("searchParams" in expected) {
assert_true("searchParams" in url)
assert_equals(url.searchParams.toString(), expected.searchParams, "searchParams")
}
assert_equals(url.hash, expected.hash, "hash")
}, "Parsing: <" + expected.input + "> against <" + expected.base + ">")
}
}
promise_test(() => fetch("resources/urltestdata.json").then(res => res.json()).then(runURLTests), "Loading data…");
</script>
-24
View File
@@ -1,24 +0,0 @@
<!doctype html>
<meta charset=utf-8>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
promise_test(() => fetch("resources/urltestdata.json").then(res => res.json()).then(runURLTests), "Loading data…");
function bURL(url, base) {
return new URL(url, base || "about:blank")
}
function runURLTests(urltests) {
for(var i = 0, l = urltests.length; i < l; i++) {
var expected = urltests[i]
if (typeof expected === "string" || !("origin" in expected)) continue
test(function() {
var url = bURL(expected.input, expected.base)
assert_equals(url.origin, expected.origin, "origin")
}, "Origin parsing: <" + expected.input + "> against <" + expected.base + ">")
}
}
</script>
+8 -8
View File
@@ -1,6 +1,6 @@
{
"common": {
"commit": "03c5072affa496c5fd2a506e5c40d23e36b5e3aa",
"commit": "dbd648158d337580885e70a54f929daf215211a0",
"path": "common"
},
"console": {
@@ -24,13 +24,9 @@
"path": "fetch/data-urls/resources"
},
"FileAPI": {
"commit": "3b279420d40afea32506e823f9ac005448f4f3d8",
"commit": "1e432c4550a1595888d7c9eb26d90895e9e7e022",
"path": "FileAPI"
},
"FileAPI/file": {
"commit": "c01f637cca43f0e08ce8e4269121dcd89ccbdd82",
"path": "FileAPI/file"
},
"hr-time": {
"commit": "34cafd797e58dad280d20040eee012d49ccfa91f",
"path": "hr-time"
@@ -64,11 +60,11 @@
"path": "resource-timing"
},
"resources": {
"commit": "fbf1e7d24776b6da144dbca45c22d39dc0512d2d",
"commit": "919874f84ff3703365063e749161a34af38c3d2a",
"path": "resources"
},
"streams": {
"commit": "9e5ef42bd34b5b19b76d0d4cb19012e52c222664",
"commit": "51750bc8d749bd80930506f603940a6bafda459f",
"path": "streams"
},
"url": {
@@ -94,5 +90,9 @@
"webidl/ecmascript-binding/es-exceptions": {
"commit": "a370aad338d6ed743abb4d2c6ae84a7f1058558c",
"path": "webidl/ecmascript-binding/es-exceptions"
},
"webmessaging/broadcastchannel": {
"commit": "e97fac4791931fb7455ba3fad759d362c7108b09",
"path": "webmessaging/broadcastchannel"
}
}
+2 -3
View File
@@ -2,6 +2,7 @@
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/gc.js"></script>
<script>
async_test(t => {
const c1 = new BroadcastChannel('blob');
@@ -27,9 +28,7 @@ async_test(t => {
(() => {
c1.postMessage({blob: new Blob(['foo', 'bar'])});
})();
// TODO(https://github.com/web-platform-tests/wpt/issues/7899): Change to
// some sort of cross-browser GC trigger.
if (self.gc) self.gc();
garbageCollect();
}, 'Blobs work on BroadcastChannel');
async_test(t => {
Loaded 100 of 108 files, more files were not shown because too many files have changed in this diff. Show more