-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibJS: Make DataView::byte_offset() return u32
This fixes structured serialization of DataView. It was expected to be uniform with TypedArray, which returns u32 for byte_offset(). This was covered by a number of WPT infrastructure tests, which this commit also imports.
- Loading branch information
1 parent
7402ae3
commit 969ee0f
Showing
22 changed files
with
2,137 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...rt/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-extra.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Summary | ||
|
||
Harness status: OK | ||
|
||
Rerun | ||
|
||
Found 2 tests | ||
|
||
2 Pass | ||
Details | ||
Result Test Name MessagePass Throwing name getter fails serialization | ||
Pass Errors sent across realms should preserve their type |
52 changes: 52 additions & 0 deletions
52
...cted/wpt-import/html/infrastructure/safe-passing-of-structured-data/structuredclone_0.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
Summary | ||
|
||
Harness status: OK | ||
|
||
Rerun | ||
|
||
Found 41 tests | ||
|
||
36 Pass | ||
5 Fail | ||
Details | ||
Result Test Name MessagePass Primitive string is cloned | ||
Pass Primitive integer is cloned | ||
Pass Primitive floating point is cloned | ||
Pass Primitive floating point (negative) is cloned | ||
Pass Primitive number (hex) is cloned | ||
Pass Primitive number (scientific) is cloned | ||
Pass Primitive boolean is cloned | ||
Pass Instance of Boolean is cloned | ||
Pass Instance of Number is cloned | ||
Pass Instance of String is cloned | ||
Pass Instance of Date is cloned | ||
Pass Instance of RegExp is cloned | ||
Pass Value 'null' is cloned | ||
Pass Value 'undefined' is cloned | ||
Pass Object properties are cloned | ||
Pass Prototype chains are not walked. | ||
Pass Property descriptors of Objects are not cloned | ||
Pass Cycles are preserved in Objects | ||
Fail Identity of duplicates is preserved | ||
Pass Property order is preserved | ||
Pass Enumerable properties of Arrays are cloned | ||
Pass Property descriptors of Arrays are not cloned | ||
Pass Cycles are preserved in Arrays | ||
Fail ImageData object can be cloned Cannot serialize platform objects | ||
Fail ImageData expandos are not cloned Cannot serialize platform objects | ||
Pass Window objects cannot be cloned | ||
Pass Document objects cannot be cloned | ||
Pass Empty Error objects can be cloned | ||
Pass Error objects can be cloned | ||
Pass EvalError objects can be cloned | ||
Pass RangeError objects can be cloned | ||
Pass ReferenceError objects can be cloned | ||
Pass SyntaxError objects can be cloned | ||
Pass TypeError objects can be cloned | ||
Pass URIError objects can be cloned | ||
Pass URIError objects from other realms are treated as URIError | ||
Pass Cloning a modified Error | ||
Pass Error.message: getter is ignored when cloning | ||
Pass Error.message: undefined property is stringified | ||
Fail DOMException objects can be cloned Cannot serialize platform objects | ||
Fail DOMException objects created by the UA can be cloned Cannot serialize platform objects |
162 changes: 162 additions & 0 deletions
162
...-import/html/infrastructure/safe-passing-of-structured-data/window-postmessage.window.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
Summary | ||
|
||
Harness status: OK | ||
|
||
Rerun | ||
|
||
Found 150 tests | ||
|
||
124 Pass | ||
25 Fail | ||
1 Optional Feature Unsupported | ||
Details | ||
Result Test Name MessagePass primitive undefined | ||
Pass primitive null | ||
Pass primitive true | ||
Pass primitive false | ||
Pass primitive string, empty string | ||
Pass primitive string, lone high surrogate | ||
Pass primitive string, lone low surrogate | ||
Pass primitive string, NUL | ||
Pass primitive string, astral character | ||
Pass primitive number, 0.2 | ||
Pass primitive number, 0 | ||
Pass primitive number, -0 | ||
Pass primitive number, NaN | ||
Pass primitive number, Infinity | ||
Pass primitive number, -Infinity | ||
Pass primitive number, 9007199254740992 | ||
Pass primitive number, -9007199254740992 | ||
Pass primitive number, 9007199254740994 | ||
Pass primitive number, -9007199254740994 | ||
Pass primitive BigInt, 0n | ||
Pass primitive BigInt, -0n | ||
Pass primitive BigInt, -9007199254740994000n | ||
Pass primitive BigInt, -9007199254740994000900719925474099400090071992547409940009007199254740994000n | ||
Pass Array primitives | ||
Pass Object primitives | ||
Pass Boolean true | ||
Pass Boolean false | ||
Pass Array Boolean objects | ||
Pass Object Boolean objects | ||
Pass String empty string | ||
Pass String lone high surrogate | ||
Pass String lone low surrogate | ||
Pass String NUL | ||
Pass String astral character | ||
Pass Array String objects | ||
Pass Object String objects | ||
Pass Number 0.2 | ||
Pass Number 0 | ||
Pass Number -0 | ||
Pass Number NaN | ||
Pass Number Infinity | ||
Pass Number -Infinity | ||
Pass Number 9007199254740992 | ||
Pass Number -9007199254740992 | ||
Pass Number 9007199254740994 | ||
Pass Number -9007199254740994 | ||
Pass BigInt -9007199254740994n | ||
Pass Array Number objects | ||
Pass Object Number objects | ||
Pass Date 0 | ||
Pass Date -0 | ||
Pass Date -8.64e15 | ||
Pass Date 8.64e15 | ||
Pass Array Date objects | ||
Pass Object Date objects | ||
Pass RegExp flags and lastIndex | ||
Pass RegExp sticky flag | ||
Pass RegExp unicode flag | ||
Pass RegExp empty | ||
Pass RegExp slash | ||
Pass RegExp new line | ||
Pass Array RegExp object, RegExp flags and lastIndex | ||
Pass Array RegExp object, RegExp sticky flag | ||
Pass Array RegExp object, RegExp unicode flag | ||
Pass Array RegExp object, RegExp empty | ||
Pass Array RegExp object, RegExp slash | ||
Pass Array RegExp object, RegExp new line | ||
Pass Object RegExp object, RegExp flags and lastIndex | ||
Pass Object RegExp object, RegExp sticky flag | ||
Pass Object RegExp object, RegExp unicode flag | ||
Pass Object RegExp object, RegExp empty | ||
Pass Object RegExp object, RegExp slash | ||
Pass Object RegExp object, RegExp new line | ||
Pass Empty Error object | ||
Pass Error object | ||
Pass EvalError object | ||
Pass RangeError object | ||
Pass ReferenceError object | ||
Pass SyntaxError object | ||
Pass TypeError object | ||
Pass URIError object | ||
Pass Blob basic | ||
Pass Blob unpaired high surrogate (invalid utf-8) | ||
Pass Blob unpaired low surrogate (invalid utf-8) | ||
Pass Blob paired surrogates (invalid utf-8) | ||
Pass Blob empty | ||
Pass Blob NUL | ||
Pass Array Blob object, Blob basic | ||
Pass Array Blob object, Blob unpaired high surrogate (invalid utf-8) | ||
Pass Array Blob object, Blob unpaired low surrogate (invalid utf-8) | ||
Pass Array Blob object, Blob paired surrogates (invalid utf-8) | ||
Pass Array Blob object, Blob empty | ||
Pass Array Blob object, Blob NUL | ||
Pass Array Blob object, two Blobs | ||
Pass Object Blob object, Blob basic | ||
Pass Object Blob object, Blob unpaired high surrogate (invalid utf-8) | ||
Pass Object Blob object, Blob unpaired low surrogate (invalid utf-8) | ||
Pass Object Blob object, Blob paired surrogates (invalid utf-8) | ||
Pass Object Blob object, Blob empty | ||
Pass Object Blob object, Blob NUL | ||
Pass File basic | ||
Pass FileList empty | ||
Pass Array FileList object, FileList empty | ||
Pass Object FileList object, FileList empty | ||
Fail ImageData 1x1 transparent black | ||
Fail ImageData 1x1 non-transparent non-black | ||
Fail Array ImageData object, ImageData 1x1 transparent black | ||
Fail Array ImageData object, ImageData 1x1 non-transparent non-black | ||
Fail Object ImageData object, ImageData 1x1 transparent black | ||
Fail Object ImageData object, ImageData 1x1 non-transparent non-black | ||
Pass Array sparse | ||
Pass Array with non-index property | ||
Pass Object with index property and length | ||
Fail Array with circular reference | ||
Fail Object with circular reference | ||
Fail Array with identical property values | ||
Fail Object with identical property values | ||
Pass Object with property on prototype | ||
Pass Object with non-enumerable property | ||
Pass Object with non-writable property | ||
Pass Object with non-configurable property | ||
Pass Object with a getter that throws | ||
Fail ImageBitmap 1x1 transparent black | ||
Fail ImageBitmap 1x1 non-transparent non-black | ||
Fail Array ImageBitmap object, ImageBitmap 1x1 transparent black | ||
Fail Array ImageBitmap object, ImageBitmap 1x1 transparent non-black | ||
Fail Object ImageBitmap object, ImageBitmap 1x1 transparent black | ||
Fail Object ImageBitmap object, ImageBitmap 1x1 transparent non-black | ||
Pass ObjectPrototype must lose its exotic-ness when cloned | ||
Pass Serializing a non-serializable platform object fails | ||
Pass An object whose interface is deleted from the global must still deserialize | ||
Pass A subclass instance will deserialize as its closest serializable superclass | ||
Fail Resizable ArrayBuffer | ||
Fail Growable SharedArrayBuffer | ||
Pass Length-tracking TypedArray | ||
Pass Length-tracking DataView | ||
Pass Serializing OOB TypedArray throws | ||
Pass Serializing OOB DataView throws | ||
Fail ArrayBuffer | ||
Fail MessagePort | ||
Fail A detached ArrayBuffer cannot be transferred | ||
Pass A detached platform object cannot be transferred | ||
Pass Transferring a non-transferable platform object fails | ||
Fail An object whose interface is deleted from the global object must still be received | ||
Optional Feature Unsupported A subclass instance will be received as its closest transferable superclass ReadableStream isn't transferable | ||
Fail Resizable ArrayBuffer is transferable | ||
Fail Length-tracking TypedArray is transferable | ||
Fail Length-tracking DataView is transferable | ||
Pass Transferring OOB TypedArray throws | ||
Pass Transferring OOB DataView throws |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const createBuffer = (() => { | ||
// See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()` | ||
let sabConstructor; | ||
try { | ||
sabConstructor = new WebAssembly.Memory({ shared:true, initial:0, maximum:0 }).buffer.constructor; | ||
} catch(e) { | ||
sabConstructor = null; | ||
} | ||
return (type, length, opts) => { | ||
if (type === "ArrayBuffer") { | ||
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, opts); | ||
} else { | ||
throw new Error("type has to be ArrayBuffer or SharedArrayBuffer"); | ||
} | ||
} | ||
})(); |
16 changes: 16 additions & 0 deletions
16
...nput/wpt-import/html/infrastructure/safe-passing-of-structured-data/messagechannel.any.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// META: global=window,worker | ||
// META: script=/common/sab.js | ||
// META: script=/html/webappapis/structured-clone/structured-clone-battery-of-tests.js | ||
// META: script=/html/webappapis/structured-clone/structured-clone-battery-of-tests-with-transferables.js | ||
// META: script=/html/webappapis/structured-clone/structured-clone-battery-of-tests-harness.js | ||
|
||
runStructuredCloneBatteryOfTests({ | ||
structuredClone(data, transfer) { | ||
return new Promise(resolve => { | ||
const channel = new MessageChannel(); | ||
channel.port2.onmessage = ev => resolve(ev.data.data); | ||
channel.port1.postMessage({data, transfer}, transfer); | ||
}); | ||
}, | ||
hasDocument : self.GLOBAL.isWindow() | ||
}); |
11 changes: 11 additions & 0 deletions
11
...wpt-import/html/infrastructure/safe-passing-of-structured-data/resources/echo-iframe.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>A test page that echos back anything postMessaged to it to its parent</title> | ||
|
||
<script> | ||
"use strict"; | ||
|
||
window.onmessage = ({ data }) => { | ||
parent.postMessage(data, "*"); | ||
}; | ||
</script> |
2 changes: 2 additions & 0 deletions
2
...rt/html/infrastructure/safe-passing-of-structured-data/resources/echo-iframe.html.headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Cross-Origin-Embedder-Policy: require-corp | ||
Cross-Origin-Resource-Policy: cross-origin |
5 changes: 5 additions & 0 deletions
5
...t/wpt-import/html/infrastructure/safe-passing-of-structured-data/resources/echo-worker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use strict"; | ||
|
||
self.onmessage = ({ data }) => { | ||
self.postMessage(data); | ||
}; |
1 change: 1 addition & 0 deletions
1
...port/html/infrastructure/safe-passing-of-structured-data/resources/echo-worker.js.headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Cross-Origin-Embedder-Policy: require-corp |
11 changes: 11 additions & 0 deletions
11
...ucture/safe-passing-of-structured-data/resources/iframe-resizable-arraybuffer-helper.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<script> | ||
|
||
window.addEventListener('message', (e) => { | ||
const buffer = e.data; | ||
e.source.postMessage(`byteLength=${buffer.byteLength},maxByteLength=${buffer.maxByteLength},resizable=${buffer.resizable}`, '*'); | ||
}); | ||
|
||
window.parent.postMessage('started', '*'); | ||
|
||
</script> |
9 changes: 9 additions & 0 deletions
9
...html/infrastructure/safe-passing-of-structured-data/resources/post-parent-type-error.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Helper that posts its parent a TypeError</title> | ||
|
||
<script> | ||
window.doIt = () => { | ||
parent.postMessage(new TypeError("!!"), "*"); | ||
}; | ||
</script> |
46 changes: 46 additions & 0 deletions
46
...t/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-extra.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Structured cloning of Error objects: extra tests</title> | ||
<script src="../../../resources/testharness.js"></script> | ||
<script src="../../../resources/testharnessreport.js"></script> | ||
|
||
<!-- Most tests are in the general framework in structuredclone_0.html. | ||
This contains specialty tests that don't fit into that framework. --> | ||
|
||
<body> | ||
|
||
<script> | ||
"use strict"; | ||
test(t => { | ||
const exceptionToThrow = new Error("throw me!"); | ||
|
||
const badError = new Error(); | ||
Object.defineProperty(badError, "name", { get() { throw exceptionToThrow; } }); | ||
|
||
const worker = new Worker("./resources/echo-worker.js"); | ||
t.add_cleanup(() => worker.terminate()); | ||
|
||
assert_throws_exactly(exceptionToThrow, () => { | ||
worker.postMessage(badError); | ||
}); | ||
}, "Throwing name getter fails serialization"); | ||
|
||
// https://bugs.chromium.org/p/chromium/issues/detail?id=1030086 | ||
// https://github.com/whatwg/html/pull/5150 | ||
async_test(t => { | ||
window.onmessage = t.step_func_done(e => { | ||
assert_equals(e.data.name, "TypeError"); | ||
}); | ||
|
||
const iframe = document.createElement("iframe"); | ||
iframe.onload = () => { | ||
if (iframe.contentWindow.location === "about:blank") { | ||
return; | ||
} | ||
|
||
iframe.contentWindow.doIt(); | ||
}; | ||
iframe.src = "resources/post-parent-type-error.html"; | ||
document.body.append(iframe); | ||
}, "Errors sent across realms should preserve their type"); | ||
</script> |
Oops, something went wrong.