Update web-platform-tests to revision 81962ac8802223d038b188b6f9cb88a0a9c5beee

This commit is contained in:
WPT Sync Bot 2018-05-18 22:02:29 -04:00
parent fe1a057bd1
commit 24183668c4
1960 changed files with 29853 additions and 10555 deletions

View file

@ -13,25 +13,18 @@
const SCOPE = '../resources/basic.html';
const BODY_METHODS = ['arrayBuffer', 'blob', 'formData', 'json', 'text'];
async function cleanup() {
for (const iframe of document.querySelectorAll('.test-iframe')) {
iframe.parentNode.removeChild(iframe);
}
const reg = await navigator.serviceWorker.getRegistration(SCOPE);
if (reg) await reg.unregister();
}
async function setupRegistration(t) {
await cleanup();
const reg = await navigator.serviceWorker.register('../resources/sw-intercept.js', { scope: SCOPE });
async function setupRegistration(t, scope) {
const reg = await navigator.serviceWorker.register('../resources/sw-intercept.js', { scope });
await wait_for_state(t, reg.installing, 'activated');
add_completion_callback(_ => reg.unregister());
return reg;
}
promise_test(async t => {
await setupRegistration(t);
const iframe = await with_iframe(SCOPE);
const scope = SCOPE + "?q=aborted-not-intercepted";
await setupRegistration(t, scope);
const iframe = await with_iframe(scope);
add_completion_callback(_ => iframe.remove());
const w = iframe.contentWindow;
const controller = new w.AbortController();
@ -56,8 +49,10 @@
for (const bodyMethod of BODY_METHODS) {
promise_test(async t => {
await setupRegistration(t);
const iframe = await with_iframe(SCOPE);
const scope = SCOPE + "?q=aborted-" + bodyMethod + "-rejects";
await setupRegistration(t, scope);
const iframe = await with_iframe(scope);
add_completion_callback(_ => iframe.remove());
const w = iframe.contentWindow;
const controller = new w.AbortController();
@ -82,8 +77,10 @@
}
promise_test(async t => {
await setupRegistration(t);
const iframe = await with_iframe(SCOPE);
const scope = SCOPE + "?q=aborted-stream-errors";
await setupRegistration(t, scope);
const iframe = await with_iframe(scope);
add_completion_callback(_ => iframe.remove());
const w = iframe.contentWindow;
const controller = new w.AbortController();

View file

@ -1,14 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: Access-Control-Expose-Headers: *</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cors-expose-star.js?pipe=sub"));
</script>
</body>
</html>

View file

@ -1,13 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: Access-Control-Expose-Headers: *</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="cors-expose-star.js?pipe=sub"></script>
</body>
</html>

View file

@ -1,7 +1,4 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
// META: script=../resources/utils.js
const url = "http://{{host}}:{{ports[http][1]}}" + dirname(location.pathname) + RESOURCES_DIR + "top.txt",
sharedHeaders = "?pipe=header(Access-Control-Expose-Headers,*)|header(Test,X)|header(Set-Cookie,X)|header(*,whoa)|"

View file

@ -1,18 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: filtered headers in CORS response</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-cors-protocol">
<meta name="help" href="https://fetch.spec.whatwg.org/#concept-filtered-response-cors">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cors-filtering.js?pipe=sub"));
</script>
</body>
</html>

View file

@ -1,17 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: filtered headers in CORS response</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-cors-protocol">
<meta name="help" href="https://fetch.spec.whatwg.org/#concept-filtered-response-cors">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="cors-filtering.js?pipe=sub"></script>
</body>
</html>

View file

@ -1,7 +1,4 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
// META: script=../resources/utils.js
function corsFilter(corsUrl, headerName, headerValue, isFiltered) {
var url = corsUrl + "?pipe=header(" + headerName + "," + encodeURIComponent(headerValue) +")|header(Access-Control-Allow-Origin,*)";
@ -52,18 +49,17 @@ corsFilter(url, "Content-Type", "text/html", false);
corsFilter(url, "Expires","04 May 1988 22:22:22 GMT" , false);
corsFilter(url, "Last-Modified", "04 May 1988 22:22:22 GMT", false);
corsFilter(url, "Pragma", "no-cache", false);
corsFilter(url, "Content-Length", "3" , false); // top.txt contains "top"
corsFilter(url, "Age", "27", true);
corsFilter(url, "Server", "wptServe" , true);
corsFilter(url, "Warning", "Mind the gap" , true);
corsFilter(url, "Content-Length", "3" , true); // top.txt contains "top"
corsFilter(url, "Set-Cookie", "name=value" , true);
corsFilter(url, "Set-Cookie2", "name=value" , true);
corsExposeFilter(url, "Age", "27", false);
corsExposeFilter(url, "Server", "wptServe" , false);
corsExposeFilter(url, "Warning", "Mind the gap" , false);
corsExposeFilter(url, "Content-Length", "3" , false);
corsExposeFilter(url, "Set-Cookie", "name=value" , true);
corsExposeFilter(url, "Set-Cookie2", "name=value" , true);

View file

@ -1,19 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: check multiple Access-Control-Allow-Origin header management</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-cors-protocol">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#cors-check">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cors-multiple-origins.js?pipe=sub"));
</script>
</body>
</html>

View file

@ -1,18 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: check multiple Access-Control-Allow-Origin header management</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-cors-protocol">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#cors-check">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="cors-multiple-origins.js?pipe=sub"></script>
</body>
</html>

View file

@ -1,32 +0,0 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
function corsMultipleOrigins(desc, originList, shouldPass) {
var urlParameters = "?origin=" + encodeURIComponent(originList.join(", "));
var url = "http://{{host}}:{{ports[http][1]}}" + dirname(location.pathname) + RESOURCES_DIR + "preflight.py";
if (shouldPass) {
promise_test(function(test) {
return fetch(url + urlParameters).then(function(resp) {
assert_equals(resp.status, 200, "Response's status is 200");
});
}, desc);
} else {
promise_test(function(test) {
return promise_rejects(test, new TypeError(), fetch(url + urlParameters));
}, desc);
}
}
/* Actual origin */
var origin = "http://{{host}}:{{ports[http][0]}}";
corsMultipleOrigins("3 origins allowed, match the 3rd (" + origin + ")", ["\"\"", "http://example.com", origin], true);
corsMultipleOrigins("3 origins allowed, match the 3rd (\"*\")", ["\"\"", "http://example.com", "*"], true);
corsMultipleOrigins("3 origins allowed, match twice (" + origin + ")", ["\"\"", origin, origin], true);
corsMultipleOrigins("3 origins allowed, match twice (\"*\")", ["*", "http://example.com", "*"], true);
corsMultipleOrigins("3 origins allowed, match twice (\"*\" and " + origin + ")", ["*", "http://example.com", origin], true);
corsMultipleOrigins("3 origins allowed, no match", ["", "http://example.com", "https://example2.com"], false);
done();

View file

@ -0,0 +1,21 @@
// META: script=../resources/utils.js
function corsMultipleOrigins(originList) {
var urlParameters = "?origin=" + encodeURIComponent(originList.join(", "));
var url = "http://{{host}}:{{ports[http][1]}}" + dirname(location.pathname) + RESOURCES_DIR + "preflight.py";
promise_test(function(test) {
return promise_rejects(test, new TypeError(), fetch(url + urlParameters));
}, "Listing multiple origins is illegal: " + originList);
}
/* Actual origin */
var origin = "http://{{host}}:{{ports[http][0]}}";
corsMultipleOrigins(["\"\"", "http://example.com", origin]);
corsMultipleOrigins(["\"\"", "http://example.com", "*"]);
corsMultipleOrigins(["\"\"", origin, origin]);
corsMultipleOrigins(["*", "http://example.com", "*"]);
corsMultipleOrigins(["*", "http://example.com", origin]);
corsMultipleOrigins(["", "http://example.com", "https://example2.com"]);
done();

View file

@ -1,17 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: rediraction loop</title>
<meta name="timeout" content="long">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("redirect-count.js"));
</script>
</body>
</html>

View file

@ -1,8 +1,5 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
importScripts("/common/utils.js");
}
// META: script=../resources/utils.js
// META: script=/common/utils.js
function redirectCount(desc, redirectUrl, redirectLocation, redirectStatus, maxCount, shouldPass) {
var uuid_token = token();

View file

@ -1,17 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: redirection loop</title>
<meta name="timeout" content="long">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="/common/utils.js"></script>
<script src="../resources/utils.js"></script>
<script src="redirect-count.js"></script>
</body>
</html>

View file

@ -1,15 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: handling empty Location header during redirection</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("redirect-empty-location.js"));
</script>
</body>
</html>

View file

@ -1,11 +1,8 @@
// META: script=../resources/utils.js
// Tests receiving a redirect response with a Location header with an empty
// value.
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
const url = RESOURCES_DIR + 'redirect-empty-location.py';
promise_test(t => {

View file

@ -1,14 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: handling empty Location header during redirection</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="redirect-empty-location.js"></script>
</body>
</html>

View file

@ -1,16 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: handling Location header during redirection</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("redirect-location.js"));
</script>
</body>
</html>

View file

@ -1,7 +1,4 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
// META: script=../resources/utils.js
function redirectLocation(desc, redirectUrl, redirectLocation, redirectStatus, redirectMode, shouldPass) {
var url = redirectUrl;

View file

@ -1,15 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: handling Location header during redirection</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="redirect-location.js"></script>
</body>
</html>

View file

@ -1,16 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: request method handling when redirected</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("redirect-method.js"));
</script>
</body>
</html>

View file

@ -1,7 +1,4 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
// META: script=../resources/utils.js
// Creates a promise_test that fetches a URL that returns a redirect response.
//

View file

@ -1,15 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: request method handling when redirected</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="redirect-method.js"></script>
</body>
</html>

View file

@ -1,17 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: redirect mode handling</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#concept-filtered-response-opaque-redirect">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("redirect-mode.js"));
</script>
</body>
</html>

View file

@ -1,7 +1,4 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("/common/get-host-info.sub.js")
}
// META: script=/common/get-host-info.sub.js
var redirectLocation = "cors-top.txt";

View file

@ -1,16 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: redirect mode handling</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#concept-filtered-response-opaque-redirect">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="/common/get-host-info.sub.js"></script>
<script src="redirect-mode.js"></script>
</body>
</html>

View file

@ -1,17 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: redirect mode handling</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#concept-filtered-response-opaque-redirect">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("redirect-origin.js"));
</script>
</body>
</html>

View file

@ -1,9 +1,6 @@
if (this.document === undefined) {
importScripts("/common/utils.js");
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
importScripts("/common/get-host-info.sub.js");
}
// META: script=/common/utils.js
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
function testOriginAfterRedirection(desc, redirectUrl, redirectLocation, redirectStatus, expectedOrigin) {
var uuid_token = token();

View file

@ -1,18 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: redirect mode handling</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#concept-filtered-response-opaque-redirect">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="/common/utils.js"></script>
<script src="../resources/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="redirect-origin.js"></script>
</body>
</html>

View file

@ -1,17 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: redirect referrer handling</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-redirect-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("redirect-referrer.js"));
</script>
</body>
</html>

View file

@ -1,9 +1,6 @@
if (this.document === undefined) {
importScripts("/common/utils.js");
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
importScripts("/common/get-host-info.sub.js");
}
// META: script=/common/utils.js
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
function testReferrerAfterRedirection(desc, redirectUrl, redirectLocation, referrerPolicy, redirectReferrerPolicy, expectedReferrer) {
var url = redirectUrl;

View file

@ -1,18 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: redirect referrer handling</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-redirect-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="/common/utils.js"></script>
<script src="../resources/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="redirect-referrer.js"></script>
</body>
</html>

View file

@ -1,14 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: data URL loading after redirections</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("redirect-to-dataurl.js"));
</script>
</body>
</html>

View file

@ -1,7 +1,4 @@
if (this.document === undefined) {
importScripts("/common/get-host-info.sub.js")
importScripts("/resources/testharness.js");
}
// META: script=/common/get-host-info.sub.js
var dataURL = "data:text/plain;base64,cmVzcG9uc2UncyBib2R5";
var body = "response's body";

View file

@ -1,13 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: data URL loading after redirections</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="/common/get-host-info.sub.js"></script>
<script src="redirect-to-dataurl.js"></script>
</body>
</html>

View file

@ -65,7 +65,7 @@ test(() => {
const reader = stream.getReader();
assert_false(response.bodyUsed, "After getting a reader");
reader.read();
reader.read().then(() => { }, () => { });
assert_true(response.bodyUsed, "After calling stream.read()");
}, "An errored stream on which read() has been called");
@ -81,7 +81,7 @@ test(() => {
const reader = stream.getReader();
assert_false(response.bodyUsed, "After getting a reader");
reader.cancel();
reader.cancel().then(() => { }, () => { });
assert_true(response.bodyUsed, "After calling stream.cancel()");
}, "An errored stream on which cancel() has been called");

View file

@ -0,0 +1,75 @@
// META: script=../resources/utils.js
promise_test(async () => {
add_completion_callback(() => delete Object.prototype.then);
const hello = new TextEncoder().encode('hello');
const bye = new TextEncoder().encode('bye');
const rs = new ReadableStream({
start(controller) {
controller.enqueue(hello);
controller.close();
}
});
const resp = new Response(rs);
Object.prototype.then = (onFulfilled) => {
delete Object.prototype.then;
onFulfilled({done: false, value: bye});
};
const text = await resp.text();
assert_equals(text, 'bye', 'The valud should be replaced with "bye".');
}, 'Inject {done: false, value: bye} via Object.prototype.then.');
promise_test(async (t) => {
add_completion_callback(() => delete Object.prototype.then);
const hello = new TextEncoder().encode('hello');
const rs = new ReadableStream({
start(controller) {
controller.enqueue(hello);
controller.close();
}
});
const resp = new Response(rs);
Object.prototype.then = (onFulfilled) => {
delete Object.prototype.then;
onFulfilled({done: false, value: undefined});
};
promise_rejects(t, TypeError(), resp.text(),
'The value should be replaced with undefined.');
}, 'Inject {done: false, value: undefined} via Object.prototype.then.');
promise_test(async (t) => {
add_completion_callback(() => delete Object.prototype.then);
const hello = new TextEncoder().encode('hello');
const rs = new ReadableStream({
start(controller) {
controller.enqueue(hello);
controller.close();
}
});
const resp = new Response(rs);
Object.prototype.then = (onFulfilled) => {
delete Object.prototype.then;
onFulfilled(undefined);
};
promise_rejects(t, TypeError(), resp.text(),
'The read result should be replaced with undefined.');
}, 'Inject undefined via Object.prototype.then.');
promise_test(async (t) => {
add_completion_callback(() => delete Object.prototype.then);
const hello = new TextEncoder().encode('hello');
const rs = new ReadableStream({
start(controller) {
controller.enqueue(hello);
controller.close();
}
});
const resp = new Response(rs);
Object.prototype.then = (onFulfilled) => {
delete Object.prototype.then;
onFulfilled(8.2);
};
promise_rejects(t, TypeError(), resp.text(),
'The read result should be replaced with a number.');
}, 'Inject 8.2 via Object.prototype.then.');