1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
5 let sb = new Cu.Sandbox('https://www.example.com',
6 { wantGlobalProperties:
7 ["crypto", "TextEncoder", "TextDecoder", "isSecureContext"],
8 forceSecureContext: true,
11 Cu.evalInSandbox('ok(this.crypto);', sb);
12 Cu.evalInSandbox('ok(this.crypto.subtle);', sb);
14 let innerPromise = new Promise(r => (sb.test_done = r));
15 Cu.evalInSandbox('crypto.subtle.digest("SHA-256", ' +
16 ' new TextEncoder().encode("abc"))' +
17 ' .then(h => equal(new Uint16Array(h)[0], 30906))' +
18 ' .then(test_done);', sb);
20 Cu.importGlobalProperties(["crypto"]);
23 let outerPromise = crypto.subtle.digest("SHA-256", new TextEncoder().encode("abc"))
24 .then(h => Assert.equal(new Uint16Array(h)[0], 30906));
27 Promise.all([innerPromise, outerPromise]).then(() => do_test_finished());