firefox-devtools / devtools-core

:rocket: Packages for Firefox DevTools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Symbol grip with actor is displayed as "Object { }"

Loirooriol opened this issue · comments

Bug 1424722 will create actors for symbols so that they can be stored as variables.

The problem is that reps seems to consider that a grip with an actor must refer to an object, and displays Object { } instead of Symbol(name). The old console frontend works fine.

Cc @nchevobbe

I can look into this :)

I need some more inputs here please, Reps detects Symbol() and displays it as Symbol.
I might not be getting the point :(

You need to add the patch from the linked bug, https://reviewboard.mozilla.org/r/207016/diff/1#index_header. It adds an actor to the symbol grip. Right now the symbol grip has no actor so it's displayed correctly.

OK, the problem is that getGripType is supposed to return "symbol" for symbol grips.

function getGripType(object, noGrip) {
  let type = typeof object;
  if (type == "object" && object instanceof String) {
    type = "string";
  } else if (object && type == "object" && object.type && noGrip !== true) {
    type = object.type;
  }

  if (isGrip(object)) {
    type = object.class;
  }

  return type;
}

But isGrip returns true is there is an actor property:

function isGrip(object) {
  return object && object.actor;
}

so object.class is returned instead, which is undefined.

As I said in some other bug, this isGrip function is too naive and unreliable, it should just be removed in favor of the noGrip parameter.

And can grips really be string objects?

I guess it should simply be something like

function getGripType(object, noGrip) {
  if (noGrip || Object(object) !== object) {
    return typeof object;
  }
  return object.type || object.class;
}

@AnshulMalik do you have some time to look at this ? I think we should move quickly here since https://bugzilla.mozilla.org/show_bug.cgi?id=1424721 landed, which means Symbol will be broken in Nightly in the next days.

I am kind of lost here @nchevobbe, trying to make sense of the code.

In fact bug 1424721 is not problematic, but I would like this to be fixed so that I can fix bug 1424722.

@AnshulMalik Currently symbol grips are like

({
  type: "symbol",
  name: "foo",
})

They will become something like

({
  type: "symbol",
  name: "foo",
  actor: "server1.conn1.child1/symbol123",
})

So getGripType needs to be updated to what I said in #842 (comment).

@AnshulMalik you can see the issue if you apply this patch :

diff --git a/packages/devtools-reps/src/reps/stubs/symbol.js b/packages/devtools-reps/src/reps/stubs/symbol.js
index 7c0c605..0ded469 100644
--- a/packages/devtools-reps/src/reps/stubs/symbol.js
+++ b/packages/devtools-reps/src/reps/stubs/symbol.js
@@ -5,11 +5,13 @@
 const stubs = new Map();
 stubs.set("Symbol", {
   type: "symbol",
-  name: "foo"
+  name: "foo",
+  actor: "server1.conn2.obj1067",
 });
 
 stubs.set("SymbolWithoutIdentifier", {
-  type: "symbol"
+  type: "symbol",
+  actor: "server1.conn2.obj1068",
 });
 
 module.exports = stubs;

and then run cd packages/devtools-reps && yarn test

You'll see the tests fail.
This is good, because we can then try to make them pass again. And for that, we need to do what @Loirooriol suggests.

Do you need more information ? Don't hesitate to ask !

Yeah, thanks @nchevobbe

I agree with @Loirooriol, isGrip is no longer needed.