diff options
Diffstat (limited to 'dom/crypto/test/test_indexedDB.html')
-rw-r--r-- | dom/crypto/test/test_indexedDB.html | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/dom/crypto/test/test_indexedDB.html b/dom/crypto/test/test_indexedDB.html new file mode 100644 index 000000000..630c16e0e --- /dev/null +++ b/dom/crypto/test/test_indexedDB.html @@ -0,0 +1,61 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="utf-8"> + <title>Bug 1188750 - WebCrypto must ensure NSS is initialized before deserializing</title> + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"?> +</head> +<body> + <script type="application/javascript;version=1.8"> + /* + * Bug 1188750 - The WebCrypto API must ensure that NSS was initialized + * for the current process before trying to deserialize objects like + * CryptoKeys from e.g. IndexedDB. + */ + "use strict"; + + const TEST_URI = "http://www.example.com/tests/" + + "dom/crypto/test/file_indexedDB.html"; + + SimpleTest.waitForExplicitFinish(); + + function createMozBrowserFrame(cb) { + let frame = document.createElement("iframe"); + SpecialPowers.wrap(frame).mozbrowser = true; + frame.src = TEST_URI; + + frame.addEventListener("mozbrowsershowmodalprompt", function onPrompt(e) { + frame.removeEventListener("mozbrowsershowmodalprompt", onPrompt); + cb(frame, e.detail.message); + }); + + document.body.appendChild(frame); + } + + function runTest() { + // Load the test app once, to generate and store keys. + createMozBrowserFrame((frame, result) => { + is(result, "ok", "stored keys successfully"); + frame.remove(); + + // Load the test app again to retrieve stored keys. + createMozBrowserFrame((frame, result) => { + is(result, "ok", "retrieved keys successfully"); + frame.remove(); + SimpleTest.finish(); + }); + }); + } + + addEventListener("load", function () { + SpecialPowers.addPermission("browser", true, document); + SpecialPowers.pushPrefEnv({set: [ + ["dom.ipc.browser_frames.oop_by_default", true], + ["dom.mozBrowserFramesEnabled", true], + ["network.disable.ipc.security", true] + ]}, runTest); + }); + </script> +</body> +</html> |