diff --git a/devtools/server/tests/unit/head_dbg.js b/devtools/server/tests/unit/head_dbg.js index 70baa259198b..086f24cfaec7 100644 --- a/devtools/server/tests/unit/head_dbg.js +++ b/devtools/server/tests/unit/head_dbg.js @@ -802,9 +802,7 @@ function getSourceContent(sourceClient) { * @returns Promise */ async function getSource(threadClient, url) { - const {sources} = await threadClient.getSources(); - const source = sources.find((s) => s.url === url); - + const source = await getSourceForm(threadClient, url); if (source) { return threadClient.source(source); } @@ -813,11 +811,15 @@ async function getSource(threadClient, url) { } async function getSourceById(threadClient, id) { - const { sources } = await threadClient.getSources(); - const form = sources.find(source => source.actor == id); + const form = await getSourceFormById(threadClient, id); return threadClient.source(form); } +async function getSourceForm(threadClient, url) { + const {sources} = await threadClient.getSources(); + return sources.find((s) => s.url === url); +} + async function getSourceFormById(threadClient, id) { const { sources } = await threadClient.getSources(); return sources.find(source => source.actor == id); diff --git a/devtools/server/tests/unit/test_blackboxing-01.js b/devtools/server/tests/unit/test_blackboxing-01.js index b93079a10c7a..01004fc0c489 100644 --- a/devtools/server/tests/unit/test_blackboxing-01.js +++ b/devtools/server/tests/unit/test_blackboxing-01.js @@ -30,6 +30,7 @@ const SOURCE_URL = "http://example.com/source.js"; const testBlackBox = async function() { const packet = await executeOnNextTickAndWaitForPause(evalCode, gClient); + const bpSource = await getSourceById( gThreadClient, packet.frame.where.actor @@ -38,9 +39,9 @@ const testBlackBox = async function() { await setBreakpoint(bpSource, { line: 2 }); await resume(gThreadClient); - const sourceClient = await getSource(gThreadClient, BLACK_BOXED_URL); + let sourceForm = await getSourceForm(gThreadClient, BLACK_BOXED_URL); - Assert.ok(!sourceClient.isBlackBoxed, + Assert.ok(!sourceForm.isBlackBoxed, "By default the source is not black boxed."); // Test that we can step into `doStuff` when we are not black boxed. @@ -58,8 +59,10 @@ const testBlackBox = async function() { } ); - await blackBox(sourceClient); - Assert.ok(sourceClient.isBlackBoxed); + const blackboxedSource = await getSource(gThreadClient, BLACK_BOXED_URL); + await blackBox(blackboxedSource); + sourceForm = await getSourceForm(gThreadClient, BLACK_BOXED_URL); + Assert.ok(sourceForm.isBlackBoxed); // Test that we step through `doStuff` when we are black boxed and its frame // doesn't show up. @@ -81,8 +84,9 @@ const testBlackBox = async function() { } ); - await unBlackBox(sourceClient); - Assert.ok(!sourceClient.isBlackBoxed); + await unBlackBox(blackboxedSource); + sourceForm = await getSourceForm(gThreadClient, BLACK_BOXED_URL); + Assert.ok(!sourceForm.isBlackBoxed); // Test that we can step into `doStuff` again. await runTest( diff --git a/devtools/shared/client/source-client.js b/devtools/shared/client/source-client.js index 89d84460b66e..d37b057d0c18 100644 --- a/devtools/shared/client/source-client.js +++ b/devtools/shared/client/source-client.js @@ -19,7 +19,6 @@ const noop = () => {}; */ function SourceClient(client, form) { this._form = form; - this._isBlackBoxed = form.isBlackBoxed; this._activeThread = client; this._client = client.client; } @@ -28,9 +27,6 @@ SourceClient.prototype = { get _transport() { return this._client._transport; }, - get isBlackBoxed() { - return this._isBlackBoxed; - }, get actor() { return this._form.actor; }, @@ -51,15 +47,6 @@ SourceClient.prototype = { }, { telemetry: "BLACKBOX", - after: function(response) { - if (!response.error) { - this._isBlackBoxed = true; - if (this._activeThread) { - this._activeThread.emit("blackboxchange", this); - } - } - return response; - }, }, ), @@ -73,15 +60,6 @@ SourceClient.prototype = { }, { telemetry: "UNBLACKBOX", - after: function(response) { - if (!response.error) { - this._isBlackBoxed = false; - if (this._activeThread) { - this._activeThread.emit("blackboxchange", this); - } - } - return response; - }, }, ),