Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / js / xpconnect / tests / unit / test_FrameScriptEnvironment.js
blobd02c9900e140a73cd16784f2b66ef399f4a842c8
1 let ppmm = Services.ppmm.getChildAt(0);
3 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
4 registerCleanupFunction(() => {
5   Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
6 });
8 add_task(async function test_bindings() {
9     let {strict, bound} = await new Promise(function(resolve) {
10         // Use a listener to get results from child
11         ppmm.addMessageListener("results", function listener(msg) {
12             ppmm.removeMessageListener("results", listener);
13             resolve(msg.data);
14         });
16         // Bind vars in first process script
17         ppmm.loadProcessScript("resource://test/environment_script.js", false);
19         // Check visibility in second process script
20         ppmm.loadProcessScript(`data:,
21             let strict = (function() { return this; })() === undefined;
22             var bound = "";
24             try { void vu; bound += "vu,"; } catch (e) {}
25             try { void vq; bound += "vq,"; } catch (e) {}
26             try { void vl; bound += "vl,"; } catch (e) {}
27             try { void gt; bound += "gt,"; } catch (e) {}
28             try { void ed; bound += "ed,"; } catch (e) {}
29             try { void ei; bound += "ei,"; } catch (e) {}
30             try { void fo; bound += "fo,"; } catch (e) {}
31             try { void fi; bound += "fi,"; } catch (e) {}
32             try { void fd; bound += "fd,"; } catch (e) {}
34             sendAsyncMessage("results", { strict, bound });
35             `, false);
36     });
38     // FrameScript loader should share |this| access
39     if (strict) {
40         if (bound != "gt,ed,ei,fo,")
41             throw new Error("Unexpected global binding set - " + bound);
42     } else {
43         if (bound != "gt,ed,ei,fo,fi,fd,")
44             throw new Error("Unexpected global binding set - " + bound);
45     }
46 });