Skip to content

Commit

Permalink
File's structured serialization should serialize lastModified attribute
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=185773

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Re-sync workers/semantics/structured-clone WPT tests after:
web-platform-tests/wpt#9218

* web-platform-tests/html/webappapis/structured-clone/structured-clone-battery-of-tests-harness.js: Added.
(runStructuredCloneBatteryOfTests):
* web-platform-tests/html/webappapis/structured-clone/structured-clone-battery-of-tests-with-transferables.js: Added.
(structuredCloneBatteryOfTests.push.async.f):
* web-platform-tests/html/webappapis/structured-clone/structured-clone-battery-of-tests.js: Renamed from LayoutTests/imported/w3c/web-platform-tests/workers/semantics/structured-clone/common.js.
(async.compare_Blob):
(get_canvas_1x1_transparent_black):
(get_canvas_1x1_non_transparent_non_black):
(compare_ImageBitmap):
(structuredCloneBatteryOfTests.push.async.f):
* web-platform-tests/html/webappapis/structured-clone/w3c-import.log: Copied from LayoutTests/imported/w3c/web-platform-tests/workers/semantics/structured-clone/w3c-import.log.
* web-platform-tests/workers/semantics/structured-clone/dedicated-expected.txt:
* web-platform-tests/workers/semantics/structured-clone/dedicated.html:
* web-platform-tests/workers/semantics/structured-clone/dedicated.js: Removed.
* web-platform-tests/workers/semantics/structured-clone/shared-expected.txt:
* web-platform-tests/workers/semantics/structured-clone/shared.html:
* web-platform-tests/workers/semantics/structured-clone/shared.js: Removed.
* web-platform-tests/workers/semantics/structured-clone/w3c-import.log:
* web-platform-tests/workers/semantics/structured-clone/worker-common.js: Removed.

Source/WebCore:

Update our implementation for the stuctured serialization of a File to include
its lastModified attribute, as per:
- https://w3c.github.io/FileAPI/#file-section

No new tests, rebaselined existing test.

* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::write):
(WebCore::CloneDeserializer::readFile):
* fileapi/File.cpp:
(WebCore::File::File):
* fileapi/File.h:

LayoutTests:

Unskip structured serialization tests that no longer fail / time out.

* TestExpectations:


Canonical link: https://commits.webkit.org/201299@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232043 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed May 22, 2018
1 parent d1d85d0 commit 25a5d43
Show file tree
Hide file tree
Showing 21 changed files with 435 additions and 1,387 deletions.
11 changes: 11 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
2018-05-21 Chris Dumez <cdumez@apple.com>

File's structured serialization should serialize lastModified attribute
https://bugs.webkit.org/show_bug.cgi?id=185773

Reviewed by Youenn Fablet.

Unskip structured serialization tests that no longer fail / time out.

* TestExpectations:

2018-05-21 Jiewen Tan <jiewen_tan@apple.com>

Unreviewed, update crypto/subtle/ecdh-import-jwk-private-key-p384.html to correct input
Expand Down
2 changes: 0 additions & 2 deletions LayoutTests/TestExpectations
Expand Up @@ -241,8 +241,6 @@ imported/w3c/web-platform-tests/workers/interfaces/WorkerUtils/importScripts/006
imported/w3c/web-platform-tests/workers/nested_worker.worker.html [ Skip ]
imported/w3c/web-platform-tests/workers/opaque-origin.html [ Skip ]
imported/w3c/web-platform-tests/workers/semantics/interface-objects/003.html [ Skip ]
imported/w3c/web-platform-tests/workers/semantics/structured-clone/shared.html [ Skip ]
imported/w3c/web-platform-tests/workers/semantics/structured-clone/dedicated.html [ Skip ]
imported/w3c/web-platform-tests/workers/semantics/multiple-workers/003.html [ Skip ]
imported/w3c/web-platform-tests/workers/semantics/multiple-workers/005.html [ Skip ]
imported/w3c/web-platform-tests/workers/Worker_cross_origin_security_err.htm [ Skip ]
Expand Down
64 changes: 33 additions & 31 deletions LayoutTests/fast/storage/serialized-script-value.html
Expand Up @@ -6,6 +6,8 @@
<body>
<script>

const currentVersion = 0x07;

// Here's a little Q&D helper for future adventurers needing to rebaseline this.

function dec2hex(n) {
Expand Down Expand Up @@ -43,7 +45,7 @@

testSerialization({foo: 'zoo', bar: {baz: 'myNewKey'}},
[
0x06, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00,
0x80, 0x66, 0x6f, 0x6f, 0x10, 0x03, 0x00, 0x00,
0x80, 0x7a, 0x6f, 0x6f, 0x03, 0x00, 0x00, 0x80,
0x62, 0x61, 0x72, 0x02, 0x03, 0x00, 0x00, 0x80,
Expand All @@ -66,15 +68,15 @@

testSerialization({foo: 'zoo', bar: 'myNewKey'},
[
0x06, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00,
0x80, 0x66, 0x6f, 0x6f, 0x10, 0x03, 0x00, 0x00,
0x80, 0x7a, 0x6f, 0x6f, 0x03, 0x00, 0x00, 0x80,
0x62, 0x61, 0x72, 0x10, 0x08, 0x00, 0x00, 0x80,
0x6d, 0x79, 0x4e, 0x65, 0x77, 0x4b, 0x65, 0x79,
0xff, 0xff, 0xff, 0xff
],
[
0x03, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00,
0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x10,
0x03, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x6f, 0x00,
0x6f, 0x00, 0x03, 0x00, 0x00, 0x00, 0x62, 0x00,
Expand All @@ -86,7 +88,7 @@

testSerialization([],
[
0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0xff
],
[
Expand All @@ -95,7 +97,7 @@
]);
testSerialization({foo: "zoo"},
[
0x06, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00,
0x80, 0x66, 0x6f, 0x6f, 0x10, 0x03, 0x00, 0x00,
0x80, 0x7a, 0x6f, 0x6f, 0xff, 0xff, 0xff, 0xff
],
Expand All @@ -107,7 +109,7 @@
]);
testSerialization({foo: null},
[
0x06, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00,
0x80, 0x66, 0x6f, 0x6f, 0x04, 0xff, 0xff, 0xff,
0xff
],
Expand All @@ -119,7 +121,7 @@

testSerialization({},
[
0x06, 0x00, 0x00, 0x00, 0x02, 0xff, 0xff, 0xff,
currentVersion, 0x00, 0x00, 0x00, 0x02, 0xff, 0xff, 0xff,
0xff
],
[
Expand All @@ -129,28 +131,28 @@

testSerialization(undefined,
[
0x06, 0x00, 0x00, 0x00, 0x03
currentVersion, 0x00, 0x00, 0x00, 0x03
],
[
0x03, 0x00, 0x00, 0x00, 0x03
]);
testSerialization(true,
[
0x06, 0x00, 0x00, 0x00, 0x09
currentVersion, 0x00, 0x00, 0x00, 0x09
],
[
0x03, 0x00, 0x00, 0x00, 0x09
]);
testSerialization(false,
[
0x06, 0x00, 0x00, 0x00, 0x08
currentVersion, 0x00, 0x00, 0x00, 0x08
],
[
0x03, 0x00, 0x00, 0x00, 0x08
]);
testSerialization(new Array(100),
[
0x06, 0x00, 0x00, 0x00, 0x01, 0x64, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x01, 0x64, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0xff
],
[
Expand All @@ -159,7 +161,7 @@
]);
testSerialization(10,
[
0x06, 0x00, 0x00, 0x00, 0x05, 0x0a, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x05, 0x0a, 0x00, 0x00,
0x00
],
[
Expand All @@ -168,7 +170,7 @@
]);
testSerialization(-10,
[
0x06, 0x00, 0x00, 0x00, 0x05, 0xf6, 0xff, 0xff,
currentVersion, 0x00, 0x00, 0x00, 0x05, 0xf6, 0xff, 0xff,
0xff
],
[
Expand All @@ -177,7 +179,7 @@
]);
testSerialization(Math.pow(2,30),
[
0x06, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
0x40
],
[
Expand All @@ -186,7 +188,7 @@
]);
testSerialization(Math.pow(2,55),
[
0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x60, 0x43,
],
[
Expand All @@ -195,7 +197,7 @@
]);
testSerialization(1.23,
[
0x06, 0x00, 0x00, 0x00, 0x0a, 0xae, 0x47, 0xe1,
currentVersion, 0x00, 0x00, 0x00, 0x0a, 0xae, 0x47, 0xe1,
0x7a, 0x14, 0xae, 0xf3, 0x3f
],
[
Expand All @@ -204,14 +206,14 @@
]);
testSerialization("",
[
0x06, 0x00, 0x00, 0x00, 0x11
currentVersion, 0x00, 0x00, 0x00, 0x11
],
[
0x03, 0x00, 0x00, 0x00, 0x11
]);
testSerialization("abc",
[
0x06, 0x00, 0x00, 0x00, 0x10, 0x03, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x10, 0x03, 0x00, 0x00,
0x80, 0x61, 0x62, 0x63
],
[
Expand All @@ -220,7 +222,7 @@
]);
testSerialization({integer: 123},
[
0x06, 0x00, 0x00, 0x00, 0x02, 0x07, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x02, 0x07, 0x00, 0x00,
0x80, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72,
0x05, 0x7b, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
0xff
Expand All @@ -233,7 +235,7 @@
]);
testSerialization({string: "str"},
[
0x06, 0x00, 0x00, 0x00, 0x02, 0x06, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x02, 0x06, 0x00, 0x00,
0x80, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x10,
0x03, 0x00, 0x00, 0x80, 0x73, 0x74, 0x72, 0xff,
0xff, 0xff, 0xff
Expand All @@ -247,7 +249,7 @@
]);
testSerialization({list: [1,2,3]},
[
0x06, 0x00, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00,
0x80, 0x6c, 0x69, 0x73, 0x74, 0x01, 0x03, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01,
0x00, 0x00, 0x00, 0x05, 0x02, 0x00, 0x00, 0x00,
Expand All @@ -266,14 +268,14 @@
]);
testSerialization(null,
[
0x06, 0x00, 0x00, 0x00, 0x04
currentVersion, 0x00, 0x00, 0x00, 0x04
],
[
0x03, 0x00, 0x00, 0x00, 0x04
]);
testSerialization(/abc/,
[
0x06, 0x00, 0x00, 0x00, 0x12, 0x03, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x12, 0x03, 0x00, 0x00,
0x80, 0x61, 0x62, 0x63, 0x00, 0x00, 0x00, 0x80
],
[
Expand All @@ -287,7 +289,7 @@
outerObject['outer'] = innerObject;
testSerialization(outerObject,
[
0x06, 0x00, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00,
0x80, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x02, 0x05,
0x00, 0x00, 0x80, 0x68, 0x65, 0x6c, 0x6c, 0x6f,
0x10, 0x05, 0x00, 0x00, 0x80, 0x74, 0x68, 0x65,
Expand All @@ -309,7 +311,7 @@
]);
testSerialization(innerObject,
[
0x06, 0x00, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00,
0x80, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x10, 0x05,
0x00, 0x00, 0x80, 0x74, 0x68, 0x65, 0x72, 0x65,
0xff, 0xff, 0xff, 0xff
Expand All @@ -325,7 +327,7 @@
var unicodeObject = {a: 'a', u: String.fromCharCode(0x03B1,0x03B2), d: 42};
testSerialization(unicodeObject,
[
0x06, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00,
0x80, 0x61, 0x10, 0xfe, 0xff, 0xff, 0xff, 0x00,
0x01, 0x00, 0x00, 0x80, 0x75, 0x10, 0x02, 0x00,
0x00, 0x00, 0xb1, 0x03, 0xb2, 0x03, 0x01, 0x00,
Expand All @@ -343,7 +345,7 @@
unicodeObject.a = 'ab';
testSerialization(unicodeObject,
[
0x06, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00,
0x80, 0x61, 0x10, 0x02, 0x00, 0x00, 0x80, 0x61,
0x62, 0x01, 0x00, 0x00, 0x80, 0x75, 0x10, 0x02,
0x00, 0x00, 0x00, 0xb1, 0x03, 0xb2, 0x03, 0x01,
Expand All @@ -368,7 +370,7 @@
arrayObject[''] = null;
testSerialization(arrayObject,
[
0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0xfd, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
0x80, 0x61, 0x09, 0x01, 0x00, 0x00, 0x80, 0x62,
0x08, 0x03, 0x00, 0x00, 0x80, 0x66, 0x6f, 0x6f,
Expand All @@ -382,7 +384,7 @@
arrayObject[1] = 'bar';
testSerialization(arrayObject,
[
0x06, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x03, 0x00,
0x00, 0x80, 0x66, 0x6f, 0x6f, 0x01, 0x00, 0x00,
0x00, 0x10, 0x03, 0x00, 0x00, 0x80, 0x62, 0x61,
Expand All @@ -403,7 +405,7 @@

testSerialization(mapObject,
[
0x06, 0x00, 0x00, 0x00, 0x1e, 0x07, 0x05, 0x02,
currentVersion, 0x00, 0x00, 0x00, 0x1e, 0x07, 0x05, 0x02,
0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf8, 0x3f, 0x02, 0xff, 0xff, 0xff,
0xff, 0x13, 0x00, 0x10, 0x03, 0x00, 0x00, 0x80,
Expand All @@ -424,7 +426,7 @@

testSerialization(setObject,
[
0x06, 0x00, 0x00, 0x00, 0x1d, 0x07, 0x0a, 0x00,
currentVersion, 0x00, 0x00, 0x00, 0x1d, 0x07, 0x0a, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x3f, 0x13,
0x00, 0x10, 0x03, 0x00, 0x00, 0x80, 0x62, 0x61,
0x72, 0x1a, 0xfe, 0xff, 0xff, 0xff, 0x00, 0x20,
Expand Down
30 changes: 30 additions & 0 deletions LayoutTests/imported/w3c/ChangeLog
@@ -1,3 +1,33 @@
2018-05-21 Chris Dumez <cdumez@apple.com>

File's structured serialization should serialize lastModified attribute
https://bugs.webkit.org/show_bug.cgi?id=185773

Reviewed by Youenn Fablet.

Re-sync workers/semantics/structured-clone WPT tests after:
https://github.com/w3c/web-platform-tests/pull/9218

* web-platform-tests/html/webappapis/structured-clone/structured-clone-battery-of-tests-harness.js: Added.
(runStructuredCloneBatteryOfTests):
* web-platform-tests/html/webappapis/structured-clone/structured-clone-battery-of-tests-with-transferables.js: Added.
(structuredCloneBatteryOfTests.push.async.f):
* web-platform-tests/html/webappapis/structured-clone/structured-clone-battery-of-tests.js: Renamed from LayoutTests/imported/w3c/web-platform-tests/workers/semantics/structured-clone/common.js.
(async.compare_Blob):
(get_canvas_1x1_transparent_black):
(get_canvas_1x1_non_transparent_non_black):
(compare_ImageBitmap):
(structuredCloneBatteryOfTests.push.async.f):
* web-platform-tests/html/webappapis/structured-clone/w3c-import.log: Copied from LayoutTests/imported/w3c/web-platform-tests/workers/semantics/structured-clone/w3c-import.log.
* web-platform-tests/workers/semantics/structured-clone/dedicated-expected.txt:
* web-platform-tests/workers/semantics/structured-clone/dedicated.html:
* web-platform-tests/workers/semantics/structured-clone/dedicated.js: Removed.
* web-platform-tests/workers/semantics/structured-clone/shared-expected.txt:
* web-platform-tests/workers/semantics/structured-clone/shared.html:
* web-platform-tests/workers/semantics/structured-clone/shared.js: Removed.
* web-platform-tests/workers/semantics/structured-clone/w3c-import.log:
* web-platform-tests/workers/semantics/structured-clone/worker-common.js: Removed.

2018-05-21 Commit Queue <commit-queue@webkit.org>

Unreviewed, rolling out r232030.
Expand Down
Expand Up @@ -4,6 +4,6 @@ PASS Type: Array, identifier: length
PASS Type: Blob, identifier: size
PASS Type: Blob, identifier: type
PASS Type: File, identifier: name
FAIL Type: File, identifier: lastModified assert_equals: Property should be used as key expected 0 but got 1
PASS Type: File, identifier: lastModified
FAIL Type: File, identifier: lastModifiedDate Provided data is inadequate.

@@ -0,0 +1,39 @@
/**
* Runs a collection of tests that determine if an API implements structured clone
* correctly.
*
* The `runner` parameter has the following properties:
* - `setup()`: An optional function run once before testing starts
* - `teardown()`: An option function run once after all tests are done
* - `preTest()`: An optional, async function run before a test
* - `postTest()`: An optional, async function run after a test is done
* - `structuredClone(obj, transferList)`: Required function that somehow
* structurally clones an object.
* - `noTransferTests`: When true, disables tests with transferables
*/

function runStructuredCloneBatteryOfTests(runner) {
const defaultRunner = {
setup() {},
preTest() {},
postTest() {},
teardown() {}
};
runner = Object.assign({}, defaultRunner, runner);

let setupPromise = runner.setup();
const allTests = structuredCloneBatteryOfTests.map(test => {

return new Promise(resolve => {
promise_test(async _ => {
test = await test;
await setupPromise;
await runner.preTest(test);
await test.f(runner)
await runner.postTest(test);
resolve();
}, test.description);
}).catch(_ => {});
});
Promise.all(allTests).then(_ => runner.teardown());
}

0 comments on commit 25a5d43

Please sign in to comment.