1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /* See https://bugzilla.mozilla.org/show_bug.cgi?id=898559 */
9 let sandbox = Cu.Sandbox("http://www.blah.com", {
10 metadata: "test metadata",
13 Cu.importGlobalProperties(["XMLHttpRequest"]);
15 Assert.equal(Cu.getSandboxMetadata(sandbox), "test metadata");
17 sandbox = Cu.Sandbox("http://www.blah.com", {
18 metadata: { foopy: { bar: 2 }, baz: "hi" }
21 let metadata = Cu.getSandboxMetadata(sandbox);
22 Assert.equal(metadata.baz, "hi");
23 Assert.equal(metadata.foopy.bar, 2);
26 metadata = Cu.getSandboxMetadata(sandbox);
27 Assert.equal(metadata.baz, "foo");
29 metadata = { foo: "bar" };
30 Cu.setSandboxMetadata(sandbox, metadata);
32 metadata = Cu.getSandboxMetadata(sandbox);
33 Assert.equal(metadata.foo, "bar");
36 let reflector = new XMLHttpRequest();
39 Cu.setSandboxMetadata(sandbox, { foo: reflector });
44 Assert.equal(thrown, true);
46 sandbox = Cu.Sandbox(this, {
47 metadata: { foopy: { bar: 2 }, baz: "hi" }
50 let inner = Cu.evalInSandbox("Components.utils.Sandbox('http://www.blah.com')", sandbox);
52 metadata = Cu.getSandboxMetadata(inner);
53 Assert.equal(metadata.baz, "hi");
54 Assert.equal(metadata.foopy.bar, 2);