Skip to content

Commit

Permalink
Fetch: add test for realm of result of Response's arrayBuffer()
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot authored May 7, 2024
1 parent 1e6ef7e commit ef64e9e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions fetch/api/response/response-arraybuffer-realm.window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// META: title=realm of Response arrayBuffer()

'use strict';

promise_test(async () => {
await new Promise(resolve => {
onload = resolve;
});

let iframe = document.createElement('iframe');
document.body.appendChild(iframe);
iframe.srcdoc = '<!doctype html>';
await new Promise(resolve => {
iframe.onload = resolve;
});

let otherRealm = iframe.contentWindow;

let ab = await window.Response.prototype.arrayBuffer.call(new otherRealm.Response(''));

assert_true(ab instanceof otherRealm.ArrayBuffer, "ArrayBuffer should be created in receiver's realm");
assert_false(ab instanceof ArrayBuffer, "ArrayBuffer should not be created in the arrayBuffer() methods's realm");
}, 'realm of the ArrayBuffer from Response arrayBuffer()');

0 comments on commit ef64e9e

Please sign in to comment.