Add tests to detect mistakes in backward compatibility when the structured clone...
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Aug 2017 20:00:49 +0000 (20:00 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Aug 2017 20:00:49 +0000 (20:00 +0000)
commitd1231e1b68860e5b957afb0ccdfa5f81ef6d4aae
tree44c1571d75637d76ab7a9e35a4447f49641d3885
parent5c0914309f7189c24c458ca78bb743a3215b4d6c
Add tests to detect mistakes in backward compatibility when the structured clone algorithm is changed in the future
https://bugs.webkit.org/show_bug.cgi?id=173998

Reviewed by Darin Adler.

Source/WebCore:

* bindings/js/SerializedScriptValue.cpp:
Add a comment.

Tools:

Since the structured clone algorithm is used for data stored in persistent databases, we need tests to help us
detect mistakes in backward compatibility in the future when we change it.

The way it works is to read from a pre-baked database and see if all the values are matched with the expectations.
Surprisedly, some of structured clonable objects cannot be stored into the indexedDB. Those are FileList,
ObjectReference, MessagePortReference, ArrayBufferView, ArrayBufferTransfer, NonMapProperties, NonSetProperties,
SharedArrayBuffer, WasmModule, DOMPointReadOnly, DOMPoint, DOMRectReadOnly, DOMRect, DOMMatrixReadOnly, DOMMatrix,
DOMQuad and Error. CryptoKey objects are not included as well as they need new API for encrypting/decrypting the
internal key data slot.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBStructuredCloneBackwardCompatibility.mm: Added.
(-[IndexedDBStructuredCloneBackwardCompatibilityMessageHandler userContentController:didReceiveScriptMessage:]):
(getNextMessage):
(TEST):
Here is the API test that moves the pre-baked database to the location where TestWebKitAPI can read from.
* TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBStructuredCloneBackwardCompatibility.sqlite3: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBStructuredCloneBackwardCompatibility.sqlite3-shm: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBStructuredCloneBackwardCompatibility.sqlite3-wal: Added.
These are the pre-baked databases.
* TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBStructuredCloneBackwardCompatibilityRead.html: Added.
This is the actual test that do all the reads and comparisons.
* TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBStructuredCloneBackwardCompatibilityWrite.html: Added.
This is the page that bakes the database. It never runs automatically. It is for someone who needs to teach
IndexedDB new stuffs. Then it can be used to bake the database again.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220109 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/SerializedScriptValue.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBStructuredCloneBackwardCompatibility.mm [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBStructuredCloneBackwardCompatibility.sqlite3 [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBStructuredCloneBackwardCompatibility.sqlite3-shm [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBStructuredCloneBackwardCompatibility.sqlite3-wal [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBStructuredCloneBackwardCompatibilityRead.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/IndexedDBStructuredCloneBackwardCompatibilityWrite.html [new file with mode: 0644]