Bug 1348885 - Prevent throwing on dead wrapper when processing stacks of error from nuked globals. r=jryans
MozReview-Commit-ID: gdFNYNzXLz
--- a/devtools/client/webconsole/test/browser_console.js
+++ b/devtools/client/webconsole/test/browser_console.js
@@ -45,16 +45,27 @@ function consoleOpened(hud) {
// Add a message from a chrome window.
hud.iframeWindow.console.log("bug587757a");
// Check Cu.reportError stack.
// Use another js script to not depend on the test file line numbers.
Services.scriptloader.loadSubScript(TEST_FILE, hud.iframeWindow);
+ // Bug 1348885: test that error from nuked globals do not throw
+ let sandbox = new Cu.Sandbox(null, {
+ wantComponents: false,
+ wantGlobalProperties: ["URL", "URLSearchParams"],
+ });
+ let error = Cu.evalInSandbox(`
+ new Error("1348885");
+ `, sandbox);
+ Cu.reportError(error);
+ Cu.nukeSandbox(sandbox);
+
// Add a message from a content window.
content.console.log("bug587757b");
// Test eval.
hud.jsterm.execute("document.location.href");
// Check for network requests.
let xhr = new XMLHttpRequest();
@@ -95,16 +106,22 @@ function consoleOpened(hud) {
line: 4,
},
// Ignore the rest of the stack,
// just assert Cu.reportError call site
// and consoleOpened call
]
},
{
+ name: "Error from nuked global works",
+ text: "1348885",
+ category: CATEGORY_JS,
+ severity: SEVERITY_ERROR,
+ },
+ {
name: "content window console.log() is displayed",
text: "bug587757b",
category: CATEGORY_WEBDEV,
severity: SEVERITY_LOG,
},
{
name: "jsterm eval result",
text: "browser.xul",
--- a/devtools/server/actors/webconsole.js
+++ b/devtools/server/actors/webconsole.js
@@ -1507,17 +1507,19 @@ WebConsoleActor.prototype =
* The page error we need to send to the client.
* @return object
* The object you can send to the remote client.
*/
preparePageErrorForRemote: function WCA_preparePageErrorForRemote(aPageError)
{
let stack = null;
// Convert stack objects to the JSON attributes expected by client code
- if (aPageError.stack) {
+ // Bug 1348885: If the global from which this error came from has been
+ // nuked, stack is going to be a dead wrapper.
+ if (aPageError.stack && !Cu.isDeadWrapper(aPageError.stack)) {
stack = [];
let s = aPageError.stack;
while (s !== null) {
stack.push({
filename: s.source,
lineNumber: s.line,
columnNumber: s.column,
functionName: s.functionDisplayName