Skip to content

Instantly share code, notes, and snippets.

@jasonLaster
Created November 9, 2020 21:58
Show Gist options
  • Select an option

  • Save jasonLaster/ce5e691a0bbd3e03daac4fe0d59588ef to your computer and use it in GitHub Desktop.

Select an option

Save jasonLaster/ce5e691a0bbd3e03daac4fe0d59588ef to your computer and use it in GitHub Desktop.
diff --git a/src/devtools/client/debugger/panel.js b/src/devtools/client/debugger/panel.js
index 14deb79d..95b73a76 100644
--- a/src/devtools/client/debugger/panel.js
+++ b/src/devtools/client/debugger/panel.js
@@ -2,39 +2,37 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
-import { defer, assert } from "protocol/utils";
+import { assert } from "protocol/utils";
import { resizeBreakpointGutter } from "./src/utils/ui";
import { openDocLink } from "devtools/client/shared/link";
import { onConnect } from "devtools/client/debugger/src/client";
-
+import { getEditor } from "devtools/client/debugger/src/utils/editor";
export class DebuggerPanel {
constructor(toolbox) {
this.toolbox = toolbox;
- this.readyWaiter = defer();
}
- async open() {
- const { actions, store, selectors, client } = await onConnect();
+ open() {
+ const { actions, store, selectors, client } = onConnect();
this._actions = actions;
this._store = store;
this._selectors = selectors;
this._client = client;
this.isReady = true;
- this.readyWaiter.resolve();
return this;
}
refresh() {
- if (!this.editor) {
- return;
- }
-
// CodeMirror does not update properly when it is hidden. This method has
// a few workarounds to get the editor to behave as expected when switching
// to the debugger from another panel and the selected location has changed.
- const { codeMirror } = this.editor.state.editor;
+ const codeMmirror = getCodeMirror();
+
+ if (!codeMmirror) {
+ return;
+ }
// Update CodeMirror by dispatching a resize event to the window. CodeMirror
// also has a refresh() method but it did not work as expected when testing.
diff --git a/src/devtools/client/debugger/src/actions/index.js b/src/devtools/client/debugger/src/actions/index.js
index ce723628..0903e310 100644
--- a/src/devtools/client/debugger/src/actions/index.js
+++ b/src/devtools/client/debugger/src/actions/index.js
@@ -22,6 +22,23 @@ import * as preview from "./preview";
import { objectInspector } from "devtools-reps";
+export function setupDebugger(store) {
+ store.dispatch(actions.connect("", ThreadFront.actor, {}, false));
+
+ ThreadFront.findSources(({ sourceId, url, sourceMapURL }) =>
+ clientEvents.newSource(ThreadFront, {
+ source: {
+ actor: sourceId,
+ url,
+ sourceMapURL,
+ },
+ })
+ );
+
+ syncBreakpoints();
+ syncXHRBreakpoints();
+}
+
export default {
...ast,
...navigation,
diff --git a/src/devtools/client/debugger/src/client/index.js b/src/devtools/client/debugger/src/client/index.js
index f9be8461..4c07228f 100644
--- a/src/devtools/client/debugger/src/client/index.js
+++ b/src/devtools/client/debugger/src/client/index.js
@@ -65,20 +65,6 @@ export function bootstrap(_store) {
store.subscribe(() => updatePrefs(store.getState()));
}
-export async function onConnect() {
- store.dispatch(actions.connect("", ThreadFront.actor, {}, false));
-
- ThreadFront.findSources(({ sourceId, url, sourceMapURL }) =>
- clientEvents.newSource(ThreadFront, {
- source: {
- actor: sourceId,
- url,
- sourceMapURL,
- },
- })
- );
-
- await syncBreakpoints();
- syncXHRBreakpoints();
+export function onConnect() {
return { store, actions: boundActions, selectors, client: clientCommands };
}
diff --git a/src/devtools/client/debugger/src/components/Editor/index.js b/src/devtools/client/debugger/src/components/Editor/index.js
index 27cfa651..c497912d 100644
--- a/src/devtools/client/debugger/src/components/Editor/index.js
+++ b/src/devtools/client/debugger/src/components/Editor/index.js
@@ -129,7 +129,7 @@ class Editor extends PureComponent {
codeMirror.on("gutterContextMenu", (cm, line, eventName, event) =>
this.onGutterContextMenu(event)
);
- codeMirror.on("contextmenu", (cm, event) => this.openMenu(event));
+ // codeMirror.on("contextmenu", (cm, event) => this.openMenu(event));
} else {
codeMirrorWrapper.addEventListener("contextmenu", event => this.openMenu(event));
}
@@ -137,8 +137,6 @@ class Editor extends PureComponent {
codeMirror.on("scroll", this.onEditorScroll);
this.onEditorScroll();
this.setState({ editor });
-
- gToolbox.getPanel("debugger").editor = this;
return editor;
}
diff --git a/src/devtools/client/debugger/src/utils/editor/index.js b/src/devtools/client/debugger/src/utils/editor/index.js
index ff67a8c2..68dd0644 100644
--- a/src/devtools/client/debugger/src/utils/editor/index.js
+++ b/src/devtools/client/debugger/src/utils/editor/index.js
@@ -29,7 +29,7 @@ export function removeEditor() {
}
function getCodeMirror() {
- return editor && editor.hasCodeMirror ? editor.codeMirror : null;
+ return editor?.codeMirror;
}
export function startOperation() {
diff --git a/src/protocol/thread/thread.d.ts b/src/protocol/thread/thread.d.ts
index d67892c1..4ed01e0c 100644
--- a/src/protocol/thread/thread.d.ts
+++ b/src/protocol/thread/thread.d.ts
@@ -55,7 +55,7 @@ export declare const ThreadFront: {
recordingId: RecordingId | null;
sessionId: SessionId | null;
sessionWaiter: Deferred<SessionId>;
- initializedWaiter: Deferred<void>;
+ // initializedWaiter: Deferred<void>;
sources: Map<string, Source>;
sourceWaiters: ArrayMap<string, () => void>;
urlSources: ArrayMap<string, SourceId>;
diff --git a/src/protocol/thread/thread.js b/src/protocol/thread/thread.js
index 747811fb..86664107 100644
--- a/src/protocol/thread/thread.js
+++ b/src/protocol/thread/thread.js
@@ -34,8 +34,8 @@ export const ThreadFront = {
sessionId: null,
sessionWaiter: defer(),
- // Waiter which resolves when the debugger has loaded and we've warped to the endpoint.
- initializedWaiter: defer(),
+ // // Waiter which resolves when the debugger has loaded and we've warped to the endpoint.
+ // initializedWaiter: defer(),
// Map sourceId to info about the source.
sources: new Map(),
@@ -94,9 +94,9 @@ export const ThreadFront = {
const { endpoint } = await sendMessage("Session.getEndpoint", {}, sessionId);
// Make sure the debugger has added a pause listener before warping to the endpoint.
- await gToolbox.startPanel("debugger");
+ gToolbox.startPanel("debugger");
this.timeWarp(endpoint.point, endpoint.time, /* hasFrames */ false, /* force */ true);
- this.initializedWaiter.resolve();
+ // this.initializedWaiter.resolve();
if (this.testName) {
sendMessage("Internal.labelTestSession", { sessionId });
@@ -468,7 +468,7 @@ export const ThreadFront = {
async _resumeOperation(command, selectedPoint) {
// Don't allow resumes until we've finished loading and did the initial
// warp to the endpoint.
- await this.initializedWaiter.promise;
+ // await this.initializedWaiter.promise;
let resumeEmitted = false;
let resumeTarget = null;
@@ -513,7 +513,7 @@ export const ThreadFront = {
},
async resumeTarget(point) {
- await this.initializedWaiter.promise;
+ // await this.initializedWaiter.promise;
return this._findResumeTarget(point, "Debugger.findResumeTarget");
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment