Skip to content

Instantly share code, notes, and snippets.

@jasonLaster
Created September 3, 2020 02:24
Show Gist options
  • Select an option

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

Select an option

Save jasonLaster/d22d92b5ac2f712be8b82b0bce286311 to your computer and use it in GitHub Desktop.
diff --git a/devtools/startup/DevToolsStartup.jsm b/devtools/startup/DevToolsStartup.jsm
index 01fceea4165e..1b727d124fc8 100644
--- a/devtools/startup/DevToolsStartup.jsm
+++ b/devtools/startup/DevToolsStartup.jsm
@@ -620,6 +620,7 @@ DevToolsStartup.prototype = {
return;
}
this.recordingButtonCreated = true;
+ this.initializeRecordingWebChannel();
createRecordingButton();
},
@@ -698,6 +699,39 @@ DevToolsStartup.prototype = {
}
},
+ initializeRecordingWebChannel() {
+ let channel;
+
+ // Register a channel for the URL in preferences. Also update the WebChannel if
+ // the URL changes.
+ const urlPref = "devtools.recordreplay.ui-base-url";
+ Services.prefs.addObserver(urlPref, registerWebChannel);
+ registerWebChannel();
+
+ function registerWebChannel() {
+ console.log(
+ `>> register recording`,
+ Services.prefs.getStringPref(urlPref)
+ );
+
+ if (channel) {
+ channel.stopListening();
+ }
+
+ const urlForWebChannel = Services.io.newURI(
+ Services.prefs.getStringPref(urlPref)
+ );
+
+ channel = new WebChannel("record-replay", urlForWebChannel);
+
+ channel.listen((id, message, target) => {
+ // Defer loading the ProfilerPopupBackground script until it's absolutely needed,
+ // as this code path gets loaded at startup.
+ console.log(`>>>> blowza`, { id, message });
+ dump(`>>> blowze ${id} ${JSON.stringify(message)}\n\n`);
+ });
+ }
+ },
/*
* We listen to the "Web Developer" system menu, which is under "Tools" main item.
* This menu item is hardcoded empty in Firefox UI. We listen for its opening to
diff --git a/toolkit/actors/WebChannelParent.jsm b/toolkit/actors/WebChannelParent.jsm
index 7fdeeaf4909e..e2815b63871d 100644
--- a/toolkit/actors/WebChannelParent.jsm
+++ b/toolkit/actors/WebChannelParent.jsm
@@ -14,6 +14,7 @@ const ERRNO_NO_SUCH_CHANNEL = 2;
class WebChannelParent extends JSWindowActorParent {
receiveMessage(msg) {
+ dump(`>>> WebChannelParent::receiveMessage \n`);
let data = msg.data.contentData;
let sendingContext = {
browsingContext: this.browsingContext,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment