Bug 872772 - Tests. r=gabor
authorBobby Holley <bobbyholley@gmail.com>
Fri, 17 May 2013 10:44:25 -0700
changeset 132258 c98f7f0305a7c0d4984354779b4791be73003b88
parent 132257 532f418b93516e1c9481991fe5b7bc71f78265f0
child 132259 4b3f1fe5c0971bfc6c13a5bd234b2a37896b0a0b
push id28184
push userbobbyholley@gmail.com
push dateFri, 17 May 2013 17:44:51 +0000
treeherdermozilla-inbound@c98f7f0305a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs872772
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 872772 - Tests. r=gabor
js/xpconnect/tests/unit/test_bug872772.js
js/xpconnect/tests/unit/xpcshell.ini
new file mode 100644
--- /dev/null
+++ b/js/xpconnect/tests/unit/test_bug872772.js
@@ -0,0 +1,41 @@
+const Cu = Components.utils;
+function run_test() {
+
+  // Make a content sandbox with an Xrayable object.
+  var contentSB = new Cu.Sandbox('http://www.google.com',
+                                 {wantXHRConstructor: true, wantComponents: true});
+
+  // Make an XHR in the content sandbox.
+  Cu.evalInSandbox('xhr = new XMLHttpRequest();', contentSB);
+
+  // Make sure that waivers can be set as Xray expandos.
+  var xhr = contentSB.xhr;
+  do_check_true(Cu.isXrayWrapper(xhr));
+  xhr.unwaivedExpando = xhr;
+  do_check_true(Cu.isXrayWrapper(xhr.unwaivedExpando));
+  var waived = xhr.wrappedJSObject;
+  do_check_true(!Cu.isXrayWrapper(waived));
+  xhr.waivedExpando = waived;
+  do_check_true(!Cu.isXrayWrapper(xhr.waivedExpando));
+
+  // Try the same thing for getters/setters, even though that's kind of
+  // contrived.
+  Cu.evalInSandbox('function f() {}', contentSB);
+  var f = contentSB.f;
+  var fWaiver = Cu.waiveXrays(f);
+  do_check_true(f != fWaiver);
+  do_check_true(Cu.unwaiveXrays(fWaiver) === f);
+  Object.defineProperty(xhr, 'waivedAccessors', {get: fWaiver, set: fWaiver});
+  var desc = Object.getOwnPropertyDescriptor(xhr, 'waivedAccessors');
+  do_check_true(desc.get === fWaiver);
+  do_check_true(desc.set === fWaiver);
+
+  // Make sure we correctly handle same-compartment security wrappers.
+  var unwaivedC = contentSB.Components;
+  do_check_true(Cu.isXrayWrapper(unwaivedC));
+  var waivedC = unwaivedC.wrappedJSObject;
+  do_check_true(waivedC && unwaivedC && (waivedC != unwaivedC));
+  xhr.waivedC = waivedC;
+  do_check_true(xhr.waivedC === waivedC);
+  do_check_true(Cu.unwaiveXrays(xhr.waivedC) === unwaivedC);
+}
--- a/js/xpconnect/tests/unit/xpcshell.ini
+++ b/js/xpconnect/tests/unit/xpcshell.ini
@@ -17,16 +17,17 @@ tail =
 [test_bug809652.js]
 [test_bug813901.js]
 [test_bug845201.js]
 [test_bug845862.js]
 [test_bug849730.js]
 [test_bug851895.js]
 [test_bug854558.js]
 [test_bug868675.js]
+[test_bug872772.js]
 [test_bug_442086.js]
 [test_file.js]
 [test_blob.js]
 [test_import.js]
 [test_import_fail.js]
 [test_js_weak_references.js]
 [test_reflect_parse.js]
 [test_localeCompare.js]