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)
This commit is contained in:
Mihai Alexandru Michis 2020-05-25 16:34:55 +03:00
Родитель 5c31755a29
Коммит 6f4fa0a560
6 изменённых файлов: 9 добавлений и 124 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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();
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -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,
});
}

Просмотреть файл

@ -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 {