Title: [153044] trunk/Source/WebInspectorUI
Revision
153044
Author
[email protected]
Date
2013-07-23 04:30:47 -0700 (Tue, 23 Jul 2013)

Log Message

WebSocket initialization to use remote inspector
https://bugs.webkit.org/show_bug.cgi?id=118678

Patch by Roland Takacs <[email protected]> on 2013-07-23
Reviewed by Timothy Hatcher.

Add WebSocket initialization and define a 'connect-src' directive in the
Content-Security-Policy HTTP header to enable the connection.

* UserInterface/InspectorFrontendHostStub.js:
(.WebInspector.InspectorFrontendHostStub.prototype.sendMessageToBackend):
* UserInterface/Main.html:
* UserInterface/Main.js:
(WebInspector.loaded):
(WebInspector._initializeWebSocketIfNeeded.createSocket.WebInspector):
(WebInspector._initializeWebSocketIfNeeded.createSocket):
(WebInspector._initializeWebSocketIfNeeded):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (153043 => 153044)


--- trunk/Source/WebInspectorUI/ChangeLog	2013-07-23 11:25:20 UTC (rev 153043)
+++ trunk/Source/WebInspectorUI/ChangeLog	2013-07-23 11:30:47 UTC (rev 153044)
@@ -1,3 +1,22 @@
+2013-07-23  Roland Takacs  <[email protected]>
+
+        WebSocket initialization to use remote inspector
+        https://bugs.webkit.org/show_bug.cgi?id=118678
+
+        Reviewed by Timothy Hatcher.
+
+        Add WebSocket initialization and define a 'connect-src' directive in the
+        Content-Security-Policy HTTP header to enable the connection.
+
+        * UserInterface/InspectorFrontendHostStub.js:
+        (.WebInspector.InspectorFrontendHostStub.prototype.sendMessageToBackend):
+        * UserInterface/Main.html:
+        * UserInterface/Main.js:
+        (WebInspector.loaded):
+        (WebInspector._initializeWebSocketIfNeeded.createSocket.WebInspector):
+        (WebInspector._initializeWebSocketIfNeeded.createSocket):
+        (WebInspector._initializeWebSocketIfNeeded):
+
 2013-07-22  Diego Pino Garcia  <[email protected]>
 
         Web Inspector: When right-clicking on a DataGrid column, show editing 

Modified: trunk/Source/WebInspectorUI/UserInterface/InspectorFrontendHostStub.js (153043 => 153044)


--- trunk/Source/WebInspectorUI/UserInterface/InspectorFrontendHostStub.js	2013-07-23 11:25:20 UTC (rev 153043)
+++ trunk/Source/WebInspectorUI/UserInterface/InspectorFrontendHostStub.js	2013-07-23 11:30:47 UTC (rev 153044)
@@ -101,6 +101,8 @@
 
         sendMessageToBackend: function(message)
         {
+            if (WebInspector.socket)
+                WebInspector.socket.send(message);
         },
 
         loadResourceSynchronously: function(url)

Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (153043 => 153044)


--- trunk/Source/WebInspectorUI/UserInterface/Main.html	2013-07-23 11:25:20 UTC (rev 153043)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html	2013-07-23 11:30:47 UTC (rev 153044)
@@ -26,7 +26,7 @@
 <html>
 <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src *; media-src *; font-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'">
+    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src *; connect-src *; media-src *; font-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'">
 
     <link rel="stylesheet" href=""
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Main.js (153043 => 153044)


--- trunk/Source/WebInspectorUI/UserInterface/Main.js	2013-07-23 11:25:20 UTC (rev 153043)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.js	2013-07-23 11:30:47 UTC (rev 153044)
@@ -32,6 +32,9 @@
     // Tell the InspectorFrontendHost we loaded first to establish communication with InspectorBackend.
     InspectorFrontendHost.loaded();
 
+    // Initialize WebSocket to communication
+    this._initializeWebSocketIfNeeded();
+
     // Register observers for events from the InspectorBackend.
     InspectorBackend.registerInspectorDispatcher(new WebInspector.InspectorObserver);
     InspectorBackend.registerPageDispatcher(new WebInspector.PageObserver);
@@ -1085,6 +1088,33 @@
     this._updateCurrentContentViewCookie(event);
 }
 
+WebInspector._initializeWebSocketIfNeeded = function()
+{
+    var ws;
+    var queryParams = parseLocationQueryParameters();
+
+    if ("ws" in queryParams)
+        ws = "ws://" + queryParams.ws;
+    else if ("page" in queryParams) {
+        var page = queryParams.page;
+        var host = "host" in queryParams ? queryParams.host : window.location.host;
+        ws = "ws://" + host + "/devtools/page/" + page;
+    }
+
+    if (!ws)
+        return;
+
+    var socket = new WebSocket(ws);
+    socket.addEventListener("open", createSocket);
+
+    function createSocket()
+    {
+        WebInspector.socket = socket;
+        WebInspector.socket.addEventListener("message", function(message) { InspectorBackend.dispatch(message.data); });
+        WebInspector.socket.addEventListener("error", function(error) { console.error(error); });
+    }
+}
+
 WebInspector._updateSplitConsoleHeight = function(height)
 {
     const minimumHeight = 64;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to