WebSocket initialization to use remote inspector

https://bugs.webkit.org/show_bug.cgi?id=118678

Patch by Roland Takacs <rtakacs@inf.u-szeged.hu> 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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153044 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 20e4d4a6
2013-07-23 Roland Takacs <rtakacs@inf.u-szeged.hu>
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 <dpino@igalia.com>
Web Inspector: When right-clicking on a DataGrid column, show editing
......
......@@ -101,6 +101,8 @@ if (!window.InspectorFrontendHost) {
sendMessageToBackend: function(message)
{
if (WebInspector.socket)
WebInspector.socket.send(message);
},
loadResourceSynchronously: function(url)
......
......@@ -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="External/CodeMirror/codemirror.css">
......
......@@ -32,6 +32,9 @@ WebInspector.loaded = function()
// 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 @@ WebInspector._contentBrowserRepresentedObjectsDidChange = function(event)
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment