Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/wasm/wasm_indexeddb_test.js

Issue 2749503002: [wasm] enable wasm structured cloning in specific cases (Closed)
Patch Set: moved frame.html Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/wasm/wasm_indexeddb_test.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/wasm/wasm_indexeddb_test.js b/third_party/WebKit/LayoutTests/http/tests/wasm/wasm_indexeddb_test.js
index 4b7cafe45ba38b5e3ee95bc5bb4fb6a20096819b..f8ca94c11b91609376e3297880747038e79d4ab9 100644
--- a/third_party/WebKit/LayoutTests/http/tests/wasm/wasm_indexeddb_test.js
+++ b/third_party/WebKit/LayoutTests/http/tests/wasm/wasm_indexeddb_test.js
@@ -32,8 +32,10 @@ function createAndSaveToIndexedDB() {
});
}
+var kErrorMsg = "failed to retrieve object";
+
function loadFromIndexedDB(prev) {
- return new Promise(resolve => {
+ return new Promise((resolve, reject) => {
prev.then(() => {
var open_request = indexedDB.open(db_name);
open_request.onsuccess = function() {
@@ -43,16 +45,34 @@ function loadFromIndexedDB(prev) {
var get_request = store.get(module_key);
get_request.onsuccess = function() {
var mod = get_request.result;
- var instance = new WebAssembly.Instance(get_request.result);
- resolve(instance.exports.increment(1));
+ if (mod instanceof WebAssembly.Module) {
+ var instance = new WebAssembly.Instance(mod);
jsbell 2017/03/22 17:41:06 Since the constructor may throw, maybe wrap in a t
Mircea Trofin 2017/03/22 23:31:15 Done.
+ resolve(instance.exports.increment(1));
+ } else {
+ reject(new Error(kErrorMsg));
jsbell 2017/03/22 17:41:07 We should be asserting something about what `mod`
Mircea Trofin 2017/03/22 23:31:15 Done.
+ }
};
};
});
});
}
-function TestIndexedDBLoadStore() {
- return loadFromIndexedDB(createAndSaveToIndexedDB())
- .then((res) => assert_equals(res, 2))
- .catch(error => assert_unreached(error));
+function TestIndexedDBLoadStoreSecure() {
+ if (window.location.origin != get_host_info().AUTHENTICATED_ORIGIN) {
+ window.location = get_host_info().AUTHENTICATED_ORIGIN + window.location.pathname;
+ } else {
+ return loadFromIndexedDB(createAndSaveToIndexedDB())
+ .then((res) => assert_equals(res, 2))
jsbell 2017/03/22 17:41:07 I don't think you want to use .then().catch() here
Mircea Trofin 2017/03/22 23:31:15 Done.
+ .catch(error => assert_unreached(error));
+ }
+}
+
+function TestIndexedDBLoadStoreInsecure() {
+ if (window.location.origin != get_host_info().UNAUTHENTICATED_ORIGIN) {
+ window.location = get_host_info().UNAUTHENTICATED_ORIGIN + window.location.pathname;
+ } else {
+ return loadFromIndexedDB(createAndSaveToIndexedDB())
+ .then(assert_unreached)
jsbell 2017/03/22 17:41:07 same as above re: two argument form of then()
Mircea Trofin 2017/03/22 23:31:15 Done.
+ .catch(error => assert_equals(error.message, kErrorMsg));
+ }
}

Powered by Google App Engine
This is Rietveld 408576698