From 6f4fa0a5605837d81810808cae8b197347150de5 Mon Sep 17 00:00:00 2001 From: Mihai Alexandru Michis Date: Mon, 25 May 2020 16:34:55 +0300 Subject: [PATCH] Backed out 2 changesets (bug 1639111) for causing failures in browser_actor_error.js CLOSED TREE Backed out changeset 2964f445c2f5 (bug 1639111) Backed out changeset 84be772b9ac4 (bug 1639111) --- devtools/server/tests/browser/browser.ini | 1 - .../tests/browser/browser_actor_error.js | 55 ++----------------- .../server/tests/browser/test-errors-actor.js | 54 ------------------ .../server/tests/chrome/test_preference.html | 9 ++- devtools/shared/protocol/Actor.js | 10 +--- devtools/shared/protocol/Front.js | 4 -- 6 files changed, 9 insertions(+), 124 deletions(-) delete mode 100644 devtools/server/tests/browser/test-errors-actor.js diff --git a/devtools/server/tests/browser/browser.ini b/devtools/server/tests/browser/browser.ini index 76cd41e1d6e0..1aeb5d51cd63 100644 --- a/devtools/server/tests/browser/browser.ini +++ b/devtools/server/tests/browser/browser.ini @@ -39,7 +39,6 @@ support-files = storage-updates.html storage-secured-iframe.html stylesheets-nested-iframes.html - test-errors-actor.js test-spawn-actor-in-parent.js test-window.xhtml inspector-helpers.js diff --git a/devtools/server/tests/browser/browser_actor_error.js b/devtools/server/tests/browser/browser_actor_error.js index f25313a457c9..00c8491ae88a 100644 --- a/devtools/server/tests/browser/browser_actor_error.js +++ b/devtools/server/tests/browser/browser_actor_error.js @@ -4,13 +4,13 @@ "use strict"; /** - * Test that clients can catch errors in actors. + * Test that clients can catch errors in old style actors. */ const ACTORS_URL = "chrome://mochitests/content/browser/devtools/server/tests/browser/error-actor.js"; -add_task(async function test_old_actor() { +async function test() { DevToolsServer.init(); DevToolsServer.registerAllActors(); @@ -36,53 +36,6 @@ add_task(async function test_old_actor() { ); await gClient.close(); -}); -const TEST_ERRORS_ACTOR_URL = - "chrome://mochitests/content/browser/devtools/server/tests/browser/test-errors-actor.js"; -add_task(async function test_protocoljs_actor() { - DevToolsServer.init(); - DevToolsServer.registerAllActors(); - - info("Register the new TestErrorsActor"); - require(TEST_ERRORS_ACTOR_URL); - ActorRegistry.registerModule(TEST_ERRORS_ACTOR_URL, { - prefix: "testErrors", - constructor: "TestErrorsActor", - type: { global: true }, - }); - - info("Create a DevTools client/server pair"); - const transport = DevToolsServer.connectPipe(); - const gClient = new DevToolsClient(transport); - await gClient.connect(); - - info("Retrieve a TestErrorsFront instance"); - const testErrorsFront = await gClient.mainRoot.getFront("testErrors"); - ok(testErrorsFront, "has a TestErrorsFront instance"); - - await Assert.rejects(testErrorsFront.throwsComponentsException(), e => { - return ( - e.message === - "NS_ERROR_NOT_IMPLEMENTED from: server0.conn1.testErrorsActor8 " + - "(chrome://mochitests/content/browser/devtools/server/tests/browser/test-errors-actor.js:41:0)" - ); - }); - await Assert.rejects(testErrorsFront.throwsException(), e => { - return ( - e.message === - 'Protocol error (TypeError): can\'t access property "b",' + - " this.a is undefined from: server0.conn1.testErrorsActor8 " + - "(chrome://mochitests/content/browser/devtools/server/tests/browser/test-errors-actor.js:46:5)" - ); - }); - await Assert.rejects(testErrorsFront.throwsJSError(), e => { - return ( - e.message === - "Protocol error (Error): JSError from: server0.conn1.testErrorsActor8 " + - "(chrome://mochitests/content/browser/devtools/server/tests/browser/test-errors-actor.js:51:11)" - ); - }); - - await gClient.close(); -}); + finish(); +} diff --git a/devtools/server/tests/browser/test-errors-actor.js b/devtools/server/tests/browser/test-errors-actor.js deleted file mode 100644 index 2d2997af505a..000000000000 --- a/devtools/server/tests/browser/test-errors-actor.js +++ /dev/null @@ -1,54 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -const protocol = require("devtools/shared/protocol"); -const { components, Cr } = require("chrome"); - -const testErrorsSpec = protocol.generateActorSpec({ - typeName: "testErrors", - - methods: { - throwsComponentsException: { - request: {}, - response: {}, - }, - throwsException: { - request: {}, - response: {}, - }, - throwsJSError: { - request: {}, - response: {}, - }, - }, -}); - -const TestErrorsActor = protocol.ActorClassWithSpec(testErrorsSpec, { - initialize: function(conn) { - protocol.Actor.prototype.initialize.call(this, conn); - this.conn = conn; - }, - - throwsComponentsException: async function() { - throw components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED); - }, - - throwsException: async function() { - return this.a.b.c; - }, - - throwsJSError: async function() { - throw new Error("JSError"); - }, -}); -exports.TestErrorsActor = TestErrorsActor; - -class TestErrorsFront extends protocol.FrontClassWithSpec(testErrorsSpec) { - constructor(client) { - super(client); - this.formAttributeName = "testErrorsActor"; - } -} -protocol.registerFront(TestErrorsFront); diff --git a/devtools/server/tests/chrome/test_preference.html b/devtools/server/tests/chrome/test_preference.html index 6c58b8061168..cd22bc122b75 100644 --- a/devtools/server/tests/chrome/test_preference.html +++ b/devtools/server/tests/chrome/test_preference.html @@ -82,12 +82,11 @@ function runTests() { next = next.then( () => ok(false, "getCharPref should've thrown for an undefined preference"), (ex) => { - const messageRe = new RegExp( - "Protocol error \\(Error\\): preference is not of the right type: " + - "test.undefined from: server0.conn0.preferenceActor1 " + - "\\(resource://devtools/server/actors/preference.js:\\d+:\\d+\\)" + is( + ex.message, + "Protocol error (unknownError): preference is not of the right type: test.undefined from: " + p.actorID, + "getCharPref should throw an exception with the preference name" ); - ok(messageRe.test(ex.message), "Error message matches the expected format"); } ); return next; diff --git a/devtools/shared/protocol/Actor.js b/devtools/shared/protocol/Actor.js index 5713bbc84726..a8d277e8cdb0 100644 --- a/devtools/shared/protocol/Actor.js +++ b/devtools/shared/protocol/Actor.js @@ -95,18 +95,10 @@ class Actor extends Pool { if (error.stack) { console.error(error.stack); } - this.conn.send({ from: this.actorID, - // error.error -> errors created using the throwError() helper - // error.name -> errors created using `new Error` or Components.exception - error: error.error || error.name || "unknownError", + error: error.error || "unknownError", message: error.message, - // error.fileName -> regular Error instances - // error.filename -> errors created using Components.exception - fileName: error.fileName || error.filename, - lineNumber: error.lineNumber, - columnNumber: error.columnNumber, }); } diff --git a/devtools/shared/protocol/Front.js b/devtools/shared/protocol/Front.js index becd48209cbc..b6a9de23543b 100644 --- a/devtools/shared/protocol/Front.js +++ b/devtools/shared/protocol/Front.js @@ -316,10 +316,6 @@ class Front extends Pool { message = packet.error; } message += " from: " + this.actorID; - if (packet.fileName) { - const { fileName, columnNumber, lineNumber } = packet; - message += ` (${fileName}:${lineNumber}:${columnNumber})`; - } const packetError = new Error(message); deferred.reject(packetError); } else {