Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / js / xpconnect / tests / unit / test_SubscriptLoaderSandboxEnvironment.js
blob3f4a10a14fb566b4a4f098f50746fb5c1cd21cbe
1 let tgt = Cu.Sandbox(Services.scriptSecurityManager.getSystemPrincipal());
3 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
4 registerCleanupFunction(() => {
5   Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
6 });
7 Services.scriptloader.loadSubScript("resource://test/environment_script.js", tgt);
9 var bound = "";
10 var tgt_bound = "";
12 // Check global bindings
13 try { void vu; bound += "vu,"; } catch (e) {}
14 try { void vq; bound += "vq,"; } catch (e) {}
15 try { void vl; bound += "vl,"; } catch (e) {}
16 try { void gt; bound += "gt,"; } catch (e) {}
17 try { void ed; bound += "ed,"; } catch (e) {}
18 try { void ei; bound += "ei,"; } catch (e) {}
19 try { void fo; bound += "fo,"; } catch (e) {}
20 try { void fi; bound += "fi,"; } catch (e) {}
21 try { void fd; bound += "fd,"; } catch (e) {}
23 // Check target bindings
24 for (var name of ["vu", "vq", "vl", "gt", "ed", "ei", "fo", "fi", "fd"])
25     if (tgt.hasOwnProperty(name))
26         tgt_bound += name + ",";
29 // Expected subscript loader behavior with a Sandbox is as follows:
30 //  - Lexicals occur on ExtensibleLexicalEnvironment of target
31 //  - Everything else occurs on Sandbox global
32 if (bound != "")
33     throw new Error("Unexpected global binding set - " + bound);
34 if (tgt_bound != "vu,vq,gt,ed,ei,fo,fi,fd,")
35     throw new Error("Unexpected target binding set - " + tgt_bound);