Bug 881480 - Add ownSymbols to onPrototypeAndProperties; r=ochameau
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Fri, 21 Jul 2017 17:17:44 +0100
changeset 419546 5806714b7da30b7201de9c7bb10f5c6898184476
parent 419545 3fa44b134c34ac76850e111c32c4b310d8fe7a08
child 419547 5a956c89da7d6cef1099189992bbe5547e0e83f2
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs881480
milestone56.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 881480 - Add ownSymbols to onPrototypeAndProperties; r=ochameau MozReview-Commit-ID: 7Mzg1UPOYcY
devtools/server/actors/object.js
devtools/server/tests/unit/test_objectgrips-16.js
devtools/server/tests/unit/xpcshell.ini
--- a/devtools/server/actors/object.js
+++ b/devtools/server/actors/object.js
@@ -251,33 +251,44 @@ ObjectActor.prototype = {
   },
 
   /**
    * Handle a protocol request to provide the prototype and own properties of
    * the object.
    */
   onPrototypeAndProperties: function () {
     let ownProperties = Object.create(null);
+    let ownSymbols = [];
     let names;
+    let symbols;
     try {
       names = this.obj.getOwnPropertyNames();
+      symbols = this.obj.getOwnPropertySymbols();
     } catch (ex) {
       // The above can throw if this.obj points to a dead object.
       // TODO: we should use Cu.isDeadWrapper() - see bug 885800.
       return { from: this.actorID,
                prototype: this.hooks.createValueGrip(null),
-               ownProperties: ownProperties,
+               ownProperties,
+               ownSymbols,
                safeGetterValues: Object.create(null) };
     }
     for (let name of names) {
       ownProperties[name] = this._propertyDescriptor(name);
     }
+    for (let sym of symbols) {
+      ownSymbols.push({
+        name: sym.toString(),
+        descriptor: this._propertyDescriptor(sym)
+      });
+    }
     return { from: this.actorID,
              prototype: this.hooks.createValueGrip(this.obj.proto),
-             ownProperties: ownProperties,
+             ownProperties,
+             ownSymbols,
              safeGetterValues: this._findSafeGetterValues(names) };
   },
 
   /**
    * Find the safe getter values for the current Debugger.Object, |this.obj|.
    *
    * @private
    * @param array ownProperties
new file mode 100644
--- /dev/null
+++ b/devtools/server/tests/unit/test_objectgrips-16.js
@@ -0,0 +1,104 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+/* eslint-disable no-shadow, max-nested-callbacks */
+
+"use strict";
+
+var gDebuggee;
+var gClient;
+var gThreadClient;
+var gCallback;
+
+function run_test() {
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+}
+
+async function run_test_with_server(server, callback) {
+  gCallback = callback;
+  initTestDebuggerServer(server);
+  gDebuggee = addTestGlobal("test-grips", server);
+  gDebuggee.eval(function stopMe(arg1) {
+    debugger;
+  }.toString());
+
+  gClient = new DebuggerClient(server.connectPipe());
+  await gClient.connect();
+  const [,, threadClient] = await attachTestTabAndResume(gClient, "test-grips");
+  gThreadClient = threadClient;
+  test_symbol_grip();
+}
+
+function test_symbol_grip() {
+  gThreadClient.addOneTimeListener("paused", function (event, packet) {
+    let args = packet.frame.arguments;
+
+    do_check_eq(args[0].class, "Object");
+
+    let objClient = gThreadClient.pauseGrip(args[0]);
+    objClient.getPrototypeAndProperties(function (response) {
+      do_check_eq(response.ownProperties.x.configurable, true);
+      do_check_eq(response.ownProperties.x.enumerable, true);
+      do_check_eq(response.ownProperties.x.writable, true);
+      do_check_eq(response.ownProperties.x.value, 10);
+
+      const [
+        firstUnnamedSymbol,
+        secondUnnamedSymbol,
+        namedSymbol,
+        iteratorSymbol,
+      ] = response.ownSymbols;
+
+      do_check_eq(firstUnnamedSymbol.name, "Symbol()");
+      do_check_eq(firstUnnamedSymbol.descriptor.configurable, true);
+      do_check_eq(firstUnnamedSymbol.descriptor.enumerable, true);
+      do_check_eq(firstUnnamedSymbol.descriptor.writable, true);
+      do_check_eq(firstUnnamedSymbol.descriptor.value, "first unnamed symbol");
+
+      do_check_eq(secondUnnamedSymbol.name, "Symbol()");
+      do_check_eq(secondUnnamedSymbol.descriptor.configurable, true);
+      do_check_eq(secondUnnamedSymbol.descriptor.enumerable, true);
+      do_check_eq(secondUnnamedSymbol.descriptor.writable, true);
+      do_check_eq(secondUnnamedSymbol.descriptor.value, "second unnamed symbol");
+
+      do_check_eq(namedSymbol.name, "Symbol(named)");
+      do_check_eq(namedSymbol.descriptor.configurable, true);
+      do_check_eq(namedSymbol.descriptor.enumerable, true);
+      do_check_eq(namedSymbol.descriptor.writable, true);
+      do_check_eq(namedSymbol.descriptor.value, "named symbol");
+
+      do_check_eq(iteratorSymbol.name, "Symbol(Symbol.iterator)");
+      do_check_eq(iteratorSymbol.descriptor.configurable, true);
+      do_check_eq(iteratorSymbol.descriptor.enumerable, true);
+      do_check_eq(iteratorSymbol.descriptor.writable, true);
+      do_check_eq(iteratorSymbol.descriptor.value.class, "Function");
+
+      do_check_true(response.prototype != undefined);
+
+      let protoClient = gThreadClient.pauseGrip(response.prototype);
+      protoClient.getOwnPropertyNames(function (response) {
+        do_check_true(response.ownPropertyNames.toString != undefined);
+
+        gThreadClient.resume(function () {
+          gClient.close().then(gCallback);
+        });
+      });
+    });
+  });
+
+  gDebuggee.eval(`
+    stopMe({
+      [Symbol()]: "first unnamed symbol",
+      [Symbol()]: "second unnamed symbol",
+      [Symbol("named")] : "named symbol",
+      [Symbol.iterator] : function* () {
+        yield 1;
+        yield 2;
+      },
+      x: 10,
+    });
+  `);
+}
+
--- a/devtools/server/tests/unit/xpcshell.ini
+++ b/devtools/server/tests/unit/xpcshell.ini
@@ -166,16 +166,17 @@ reason = only ran on B2G
 [test_objectgrips-08.js]
 [test_objectgrips-09.js]
 [test_objectgrips-10.js]
 [test_objectgrips-11.js]
 [test_objectgrips-12.js]
 [test_objectgrips-13.js]
 [test_objectgrips-14.js]
 [test_objectgrips-15.js]
+[test_objectgrips-16.js]
 [test_promise_state-01.js]
 [test_promise_state-02.js]
 [test_promise_state-03.js]
 [test_interrupt.js]
 [test_stepping-01.js]
 [test_stepping-02.js]
 [test_stepping-03.js]
 [test_stepping-04.js]