Created
October 29, 2019 16:48
-
-
Save ochameau/aabe8c67aee50ec530cb653803ba1392 to your computer and use it in GitHub Desktop.
Load application panel OOP (BROKEN!)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 937187b5f15df622f08230e52e52c1d2a040e480 | |
Author: Alexandre Poirot <[email protected]> | |
Date: Thu May 10 10:28:23 2018 -0700 | |
oop pipeline | |
MozReview-Commit-ID: 4bUO2sK7Guf | |
diff --git a/devtools/client/framework/target-from-url.js b/devtools/client/framework/target-from-url.js | |
index 5dcbff79f907..2f4c35fec0ec 100644 | |
--- a/devtools/client/framework/target-from-url.js | |
+++ b/devtools/client/framework/target-from-url.js | |
@@ -41,12 +41,14 @@ const { remoteClientManager } = | |
*/ | |
exports.targetFromURL = async function targetFromURL(url) { | |
const client = await clientFromURL(url); | |
+ dump("connect\n"); | |
const params = url.searchParams; | |
// Clients retrieved from the remote-client-manager are already connected. | |
if (!params.get("remoteId")) { | |
// Connect any other client. | |
await client.connect(); | |
+ dump("connected\n"); | |
} | |
const type = params.get("type"); | |
@@ -144,7 +146,24 @@ async function clientFromURL(url) { | |
const webSocket = !!params.get("ws"); | |
let transport; | |
- if (port) { | |
+ if (true) { | |
+ const { ChildDebuggerTransport } = require("devtools/shared/transport/transport"); | |
+ const Services = require("Services"); | |
+ transport = new ChildDebuggerTransport(Services.cpmm, "oop-client", true); | |
+ transport.hooks = { | |
+ onPacket(p) { | |
+ dump("receive packet in frontend\n"); | |
+ }, | |
+ onClosed() {} | |
+ }; | |
+ transport.ready(); | |
+ dump("set up transport in frontend\n"); | |
+ /* | |
+ DebuggerServer.init(); | |
+ DebuggerServer.registerAllActors(); | |
+ transport = DebuggerServer.connectParent(); | |
+ */ | |
+ } else if (port) { | |
transport = await DebuggerClient.socketConnect({ host, port, webSocket }); | |
} else { | |
// Setup a server if we don't have one already running | |
diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js | |
index 332c579ce09f..1339ce56df67 100644 | |
--- a/devtools/client/framework/toolbox.js | |
+++ b/devtools/client/framework/toolbox.js | |
@@ -1880,6 +1880,21 @@ Toolbox.prototype = { | |
let url = definition.url; | |
if (iframe.getAttribute("remote") === "true") { | |
+ const { ChildDebuggerTransport } = | |
+ require("devtools/shared/transport/transport"); | |
+ let childTransport = new ChildDebuggerTransport(Services.ppmm, "oop-client", true); | |
+ let connection = this.target.client._transport; | |
+ childTransport.hooks = { | |
+ onPacket(p) { | |
+ dump("receive packet in parent\n"); | |
+ return connection.send(p); | |
+ }, | |
+ onClosed() {} | |
+ }; | |
+ childTransport.ready(); | |
+ const { DebuggerServer } = require("devtools/server/main"); | |
+ DebuggerServer.connectChildTransport(childTransport, "oop-client"); | |
+ dump("created transport in parent\n"); | |
url += "?host=localhost&port=6000&type=tab&id=" + this.target.tab.linkedBrowser.outerWindowID; | |
} | |
iframe.setAttribute("src", url); | |
diff --git a/devtools/server/main.js b/devtools/server/main.js | |
index 806549b194e3..14590c7e2d9d 100644 | |
--- a/devtools/server/main.js | |
+++ b/devtools/server/main.js | |
@@ -269,6 +269,13 @@ var DebuggerServer = { | |
return clientTransport; | |
}, | |
+ connectChildTransport(childTransport, prefix) { | |
+ let clientTransport = new LocalDebuggerTransport(childTransport); | |
+ clientTransport.other = childTransport; | |
+ let connection = this._onConnection(childTransport, prefix); | |
+ return clientTransport; | |
+ }, | |
+ | |
/** | |
* In a content child process, create a new connection that exchanges | |
* nsIMessageSender messages with our parent process. | |
diff --git a/devtools/shared/transport/child-transport.js b/devtools/shared/transport/child-transport.js | |
index 383a1ef36762..41814f443300 100644 | |
--- a/devtools/shared/transport/child-transport.js | |
+++ b/devtools/shared/transport/child-transport.js | |
@@ -21,9 +21,10 @@ const flags = require("devtools/shared/flags"); | |
* This transport exchanges messages named 'debug:<prefix>:packet', where | |
* <prefix> is |prefix|, whose data is the protocol packet. | |
*/ | |
-function ChildDebuggerTransport(mm, prefix) { | |
+function ChildDebuggerTransport(mm, prefix, log) { | |
this._mm = mm; | |
this._messageName = "debug:" + prefix + ":packet"; | |
+ this.log = log; | |
} | |
/* | |
@@ -63,6 +64,9 @@ ChildDebuggerTransport.prototype = { | |
}, | |
receiveMessage: function({data}) { | |
+ if (this.log) { | |
+ dump("receiveMessage\n"); | |
+ } | |
this.hooks.onPacket(data); | |
}, | |
@@ -95,6 +99,9 @@ ChildDebuggerTransport.prototype = { | |
}, | |
send: function(packet) { | |
+ if (this.log) { | |
+ dump("send\n"); | |
+ } | |
if (flags.testing && !this._canBeSerialized(packet)) { | |
const attributes = this.pathToUnserializable(packet); | |
let msg = "Following packet can't be serialized: " + JSON.stringify(packet); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit cae06cab6c8c299373362427b011c7bf20c54c67 | |
Author: Alexandre Poirot <[email protected]> | |
Date: Wed May 9 09:46:16 2018 -0700 | |
OOP experiment | |
MozReview-Commit-ID: 9EKdosr9mM3 | |
diff --git a/devtools/client/application/initializer.js b/devtools/client/application/initializer.js | |
index 7a541f78d8b8..4c03b122a5eb 100644 | |
--- a/devtools/client/application/initializer.js | |
+++ b/devtools/client/application/initializer.js | |
@@ -27,7 +27,7 @@ const App = createFactory(require("./src/components/App")); | |
* called to start the UI for the panel. | |
*/ | |
window.Application = { | |
- async bootstrap({ toolbox, panel }) { | |
+ async bootstrap({ toolbox }) { | |
this.updateWorkers = this.updateWorkers.bind(this); | |
this.updateDomain = this.updateDomain.bind(this); | |
@@ -114,3 +114,34 @@ window.Application = { | |
this.client = null; | |
}, | |
}; | |
+ | |
+ | |
+// URL constructor doesn't support chrome: scheme | |
+let href = window.location.href.replace(/chrome:/, "http://"); | |
+let url = new window.URL(href); | |
+ | |
+// If query parameters are given in a chrome tab, the inspector | |
+// is running in standalone. | |
+if (window.location.protocol === "chrome:" && url.search.length > 1) { | |
+ const { targetFromURL } = require("devtools/client/framework/target-from-url"); | |
+ | |
+ (async function() { | |
+ try { | |
+dump("application go call targetFromURL\n"); | |
+ let target = await targetFromURL(url); | |
+dump("application got target\n"); | |
+ | |
+ // Create a fake toolbox object | |
+ let toolbox = { | |
+ target, | |
+ }; | |
+ | |
+dump("application go call bootstrap: "+window.Application.bootstrap+"\n"); | |
+ await window.Application.bootstrap({ toolbox }); | |
+dump("application bootstrap called\n"); | |
+ } catch (err) { | |
+dump("application err: "+err+"\n"); | |
+ window.alert("Unable to start application panel:" + err); | |
+ } | |
+ })(); | |
+} | |
diff --git a/devtools/client/application/panel.js b/devtools/client/application/panel.js | |
index a6c0dda8e521..02cdfa17826c 100644 | |
--- a/devtools/client/application/panel.js | |
+++ b/devtools/client/application/panel.js | |
@@ -34,7 +34,9 @@ class ApplicationPanel { | |
} | |
destroy() { | |
- this.panelWin.Application.destroy(); | |
+ if (this.panelWin) { | |
+ this.panelWin.Application.destroy(); | |
+ } | |
this.panelWin = null; | |
this.toolbox = null; | |
this.emit("destroyed"); | |
diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js | |
index 7d68bed8d4a7..332c579ce09f 100644 | |
--- a/devtools/client/framework/toolbox.js | |
+++ b/devtools/client/framework/toolbox.js | |
@@ -1776,13 +1776,26 @@ Toolbox.prototype = { | |
return; | |
} | |
- iframe = this.doc.createXULElement("iframe"); | |
+ if (id == "oop" || id == "application") { | |
+ // XUL:iframe doesn't work with remote="true" | |
+ // XUL:browser throws on creation... | |
+ iframe = this.doc.createElementNS("http://www.w3.org/1999/xhtml", "iframe"); | |
+ } else { | |
+ iframe = this.doc.createElement("iframe"); | |
+ } | |
iframe.className = "toolbox-panel-iframe"; | |
iframe.id = "toolbox-panel-iframe-" + id; | |
iframe.setAttribute("flex", 1); | |
iframe.setAttribute("forceOwnRefreshDriver", ""); | |
iframe.tooltip = "aHTMLTooltip"; | |
iframe.style.visibility = "hidden"; | |
+ if (id == "oop" || id == "application") { | |
+ iframe.setAttribute("remote", "true"); | |
+ iframe.setAttribute("mozbrowser", "true"); | |
+ // Taken from RDM, should be reviewed: | |
+ iframe.setAttribute("noisolation", "true"); | |
+ iframe.setAttribute("remotetype", "web"); | |
+ } | |
gDevTools.emit(id + "-init", this, iframe); | |
this.emit(id + "-init", iframe); | |
@@ -1865,10 +1878,20 @@ Toolbox.prototype = { | |
}, console.error); | |
}; | |
- iframe.setAttribute("src", definition.url); | |
+ let url = definition.url; | |
+ if (iframe.getAttribute("remote") === "true") { | |
+ url += "?host=localhost&port=6000&type=tab&id=" + this.target.tab.linkedBrowser.outerWindowID; | |
+ } | |
+ iframe.setAttribute("src", url); | |
if (definition.panelLabel) { | |
iframe.setAttribute("aria-label", definition.panelLabel); | |
} | |
+ // If no parent yet, append the frame into default location. | |
+ if (!iframe.parentNode) { | |
+ let vbox = this.doc.getElementById("toolbox-panel-" + id); | |
+ vbox.appendChild(iframe); | |
+ vbox.visibility = "visible"; | |
+ } | |
// Depending on the host, iframe.contentWindow is not always | |
// defined at this moment. If it is not defined, we use an | |
@@ -1876,7 +1899,9 @@ Toolbox.prototype = { | |
// we use the chromeEventHandler. We can't use a listener | |
// on the DOM node every time because this won't work | |
// if the (xul chrome) iframe is loaded in a content docshell. | |
- if (iframe.contentWindow) { | |
+ if (iframe.getAttribute("remote") === "true") { | |
+ onLoad(); | |
+ } else if (iframe.getAttribute("remote") !== "true" && iframe.contentWindow) { | |
const domHelper = new DOMHelpers(iframe.contentWindow); | |
domHelper.onceDOMReady(onLoad); | |
} else { | |
@@ -1896,6 +1921,9 @@ Toolbox.prototype = { | |
* @param {IFrameElement} iframe | |
*/ | |
setIframeDocumentDir: function(iframe) { | |
+ if (iframe.getAttribute("remote") === "true") { | |
+ return; | |
+ } | |
const docEl = iframe.contentWindow && iframe.contentWindow.document.documentElement; | |
if (!docEl || docEl.namespaceURI !== HTML_NS) { | |
// Bail out if the content window or document is not ready or if the document is not | |
@@ -1953,6 +1981,9 @@ Toolbox.prototype = { | |
* background. | |
*/ | |
setIframeVisible: function(iframe, visible) { | |
+ if (iframe.getAttribute("remote") === "true") { | |
+ return; | |
+ } | |
const state = visible ? "visible" : "hidden"; | |
const win = iframe.contentWindow; | |
const doc = win.document; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment