Open Bug 1440464 Opened 6 years ago Updated 2 years ago

console.time / console.timeEnd throws an error when used from a jsm without using a console created via createInstance

Categories

(DevTools :: Console, defect, P3)

defect

Tracking

(firefox60 affected)

Tracking Status
firefox60 --- affected

People

(Reporter: bgrins, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

Originally posted in https://bugzilla.mozilla.org/show_bug.cgi?id=1430810#c12:

After re-testing with Bug 1433625 resolved I'm now seeing a different error on both devtools/client/webconsole/test/browser_console_consolejsm_output.js and with the LightweightThemeManager example script in Comment 10. If I include these lines in LightweightThemeManager.jsm:

  console.log("LightweightThemeManager.jsm");
  console.time("LightweightThemeManager.jsm timer");
  console.timeEnd("LightweightThemeManager.jsm timer");

Then when I `./mach run --jsconsole` I see an error in the Browser Console:

  Error: Timer “LightweightThemeManager.jsm timer” doesn’t exist.
  Stack trace:
  logConsoleAPIMessage@resource://devtools/shared/base-loader.js -> resource://devtools/client/webconsole/webconsole.js:1278:25
  _outputMessageFromQueue@resource://devtools/shared/base-loader.js -> resource://devtools/client/webconsole/webconsole.js:2103:16
  _flushMessageQueue@resource://devtools/shared/base-loader.js -> resource://devtools/client/webconsole/webconsole.js:1992:20

We are receiving this packet from the actor which means we are somehow hitting the eTimerDoesntExist case in Console.cpp:

  {
    "addonId": "",
    "arguments": [
      "LightweightThemeManager.jsm timer"
    ],
    "columnNumber": 3,
    "counter": null,
    "filename": "resource://gre/modules/LightweightThemeManager.jsm",
    "functionName": "",
    "groupName": "",
    "level": "timeEnd",
    "lineNumber": 20,
    "prefix": "",
    "private": false,
    "timeStamp": 1517266277688,
    "timer": {
      "error": "timerDoesntExist",
      "name": "LightweightThemeManager.jsm timer"
    },
    "workerType": "none",
    "styles": [],
    "category": "webdev",
    "_type": "ConsoleAPI"
  }

Here's the interesting thing - If I do this script instead it works just as expected:

  var c = console.createInstance();
  c.log("LightweightThemeManager.jsm");
  c.time("LightweightThemeManager.jsm timer");
  c.timeEnd("LightweightThemeManager.jsm timer");

So I guess this only is an issue when using the webidl console global directly from a JSM, and it's not a problem when first calling createInstance.
Moving needinfo from Bug 1430810
Flags: needinfo?(amarchesini)
We need to have BackstagePass CCed in order to implement this feature.
Depends on: 1137770
Flags: needinfo?(amarchesini)
Product: Firefox → DevTools
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.