Bug 1071177 - Test
authorTom Schuster <evilpies@gmail.com>
Tue, 07 Oct 2014 11:29:03 +0200
changeset 232350 435e1a7b1a347e2ca5a564f4c45625e50fef3e05
parent 232349 2279791b5c6e8d55675db58f38ccfcba7c568ca9
child 232351 aad7264777993babeac9991c80cd29ea9a421f38
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1071177
milestone35.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 1071177 - Test
content/base/test/chrome/cpows_child.js
content/base/test/chrome/cpows_parent.xul
--- a/content/base/test/chrome/cpows_child.js
+++ b/content/base/test/chrome/cpows_child.js
@@ -110,16 +110,31 @@ function dom_test()
 function xray_test()
 {
   let element = content.document.createElement("div");
   element.wrappedJSObject.foo = "hello";
 
   sendSyncMessage("cpows:xray_test", {}, {element: element});
 }
 
+function symbol_test()
+{
+  let iterator = Symbol.iterator;
+  let named = Symbol.for("cpow-test");
+  // let unique = Symbol();
+
+  let object = {
+    [iterator]: iterator,
+    [named]: named,
+    // [unique]: unique,
+    // "unique": unique
+  };
+  sendSyncMessage("cpows:symbol_test", {}, object);
+}
+
 // Parent->Child references should go X->parent.privilegedJunkScope->child.privilegedJunkScope->Y
 // Child->Parent references should go X->child.privilegedJunkScope->parent.unprivilegedJunkScope->Y
 function compartment_test()
 {
   // This test primarily checks various compartment invariants for CPOWs, and
   // doesn't make sense to run in-process.
   if (!is_remote) {
     return;
--- a/content/base/test/chrome/cpows_parent.xul
+++ b/content/base/test/chrome/cpows_parent.xul
@@ -200,16 +200,23 @@
       is(id, "it_works", "DOM element has expected ID");
     }
 
     function recvXrayTest(message) {
       let element = message.objects.element;
       is(element.foo, undefined, "DOM element does not expose content properties");
     }
 
+    function recvSymbolTest(message) {
+      let object = message.objects;
+      is(object[Symbol.iterator], Symbol.iterator, "Should use Symbol.iterator");
+      is(Symbol.keyFor(object[Symbol.for("cpow-test")]), "cpow-test", "Symbols aren't registered correctly");
+      // is(object.unique, object[object.unique], "Unique symbols as ids and values don't seem to work");
+    }
+
     let systemGlobal = this;
     function recvCompartmentTest(message) {
       let getUnprivilegedObject = message.objects.getUnprivilegedObject;
       let testParentObject = message.objects.testParentObject;
 
       // Make sure that parent->child CPOWs live in the parent's privileged junk scope.
       let unprivilegedObject = getUnprivilegedObject();
       is(Cu.getGlobalForObject(getUnprivilegedObject),
@@ -295,16 +302,17 @@
       mm.addMessageListener("cpows:reenter_sync", recvReenterSyncMessage);
       mm.addMessageListener("cpows:done", recvDoneMessage);
       mm.addMessageListener("cpows:fail", recvFailMessage);
       mm.addMessageListener("cpows:parent_test", recvParentTest);
       mm.addMessageListener("cpows:error_reporting_test", recvErrorReportingTest);
       mm.addMessageListener("cpows:dom_test", recvDomTest);
       mm.addMessageListener("cpows:dom_test_after_gc", recvDomTestAfterGC);
       mm.addMessageListener("cpows:xray_test", recvXrayTest);
+      mm.addMessageListener("cpows:symbol_test", recvSymbolTest);
       mm.addMessageListener("cpows:compartment_test", recvCompartmentTest);
       mm.addMessageListener("cpows:regexp_test", recvRegExpTest);
       mm.addMessageListener("cpows:lifetime_test_1", recvLifetimeTest1);
       mm.addMessageListener("cpows:lifetime_test_2", recvLifetimeTest2);
       mm.loadFrameScript("chrome://mochitests/content/chrome/content/base/test/chrome/cpows_child.js", true);
     }
 
     function start() {