Title: [126709] trunk
Revision
126709
Author
[email protected]
Date
2012-08-26 11:42:41 -0700 (Sun, 26 Aug 2012)

Log Message

Web Inspector: make ConsoleView listen to the _javascript_ContextManager
https://bugs.webkit.org/show_bug.cgi?id=94940

Reviewed by Vsevolod Vlasov.

Source/WebCore:

Otherwise, model is pushing data into the UI.

* inspector/front-end/ConsoleMessage.js:
(WebInspector.ConsoleMessageImpl.prototype.clone):
* inspector/front-end/ConsoleView.js:
(WebInspector.ConsoleView.prototype._contextAdded):
(WebInspector.ConsoleView.prototype._addContext):
(WebInspector.ConsoleView.prototype._contextRemoved):
* inspector/front-end/_javascript_ContextManager.js:
(WebInspector._javascript_ContextManager):
(WebInspector._javascript_ContextManager.prototype.contexts):
(WebInspector._javascript_ContextManager.prototype._frameAdded):
(WebInspector._javascript_ContextManager.prototype._frameDetached):
* inspector/front-end/ParsedURL.js:
(WebInspector.ParsedURL.completeURL):
(WebInspector.TextEditorDelegateForSourceFrame.prototype.createLink):
* inspector/front-end/inspector.js:

LayoutTests:

* inspector/elements/elements-panel-rewrite-href-expected.txt:
* inspector/styles/styles-url-linkify-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (126708 => 126709)


--- trunk/LayoutTests/ChangeLog	2012-08-26 18:23:54 UTC (rev 126708)
+++ trunk/LayoutTests/ChangeLog	2012-08-26 18:42:41 UTC (rev 126709)
@@ -1,3 +1,13 @@
+2012-08-26  Pavel Feldman  <[email protected]>
+
+        Web Inspector: make ConsoleView listen to the _javascript_ContextManager
+        https://bugs.webkit.org/show_bug.cgi?id=94940
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/elements/elements-panel-rewrite-href-expected.txt:
+        * inspector/styles/styles-url-linkify-expected.txt:
+
 2012-08-26  Filip Pizlo  <[email protected]>
 
         Don't allocate space for arguments and call frame if arguments aren't captured

Modified: trunk/LayoutTests/inspector/elements/elements-panel-rewrite-href-expected.txt (126708 => 126709)


--- trunk/LayoutTests/inspector/elements/elements-panel-rewrite-href-expected.txt	2012-08-26 18:23:54 UTC (rev 126708)
+++ trunk/LayoutTests/inspector/elements/elements-panel-rewrite-href-expected.txt	2012-08-26 18:42:41 UTC (rev 126709)
@@ -1,6 +1,6 @@
 Tests that src and href element targets are rewritten properly.
 
-null
+ _javascript_:alert('foo') 
 ,bogusSheet1.css
 inspector,elements,bogusSheet2.css
 tests,inspector,inspector-test.js

Modified: trunk/LayoutTests/inspector/styles/styles-url-linkify-expected.txt (126708 => 126709)


--- trunk/LayoutTests/inspector/styles/styles-url-linkify-expected.txt	2012-08-26 18:23:54 UTC (rev 126708)
+++ trunk/LayoutTests/inspector/styles/styles-url-linkify-expected.txt	2012-08-26 18:42:41 UTC (rev 126709)
@@ -19,7 +19,7 @@
 http://example.com/cat.jpeg
 http://example.com/cat.jpeg
 data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAABCAgMAAACeOuh7AAAABGdBTUEAAK/INwWK6QAAAAlQTFRF////AAAA////fu+PTwAAAAF0Uk5TAEDm2GYAAACHSURBVDjLxdLbDYAgDAVQGELn0R3oEHYf2KGdUqtE46OFRCP3oyTng1xCnWsaD5JRRtCkQ2YmkBkHRXqWJBn0j0TICbrsWVoWhRShCdcGyZCtHxMaUnVPRZ9KSbmBJdsX2vJVnwqRD0Rb4rpzgIbE/AI5NTnWAMvy5l0dXrfuLh5OCe5BmmYGXhTUxlQ5xJ8AAAAASUVORK5CYII=
-null
+_javascript_:alert('foo');
 blob:http%3A//example.com/f91b7b00-00-0000-0000-3b7c87055d7a
 blob:http%3A//example.com/f91b7b00-00-0000-0000-3b7c87055d7a
 Link for a URI from CSS document:

Modified: trunk/Source/WebCore/ChangeLog (126708 => 126709)


--- trunk/Source/WebCore/ChangeLog	2012-08-26 18:23:54 UTC (rev 126708)
+++ trunk/Source/WebCore/ChangeLog	2012-08-26 18:42:41 UTC (rev 126709)
@@ -1,5 +1,30 @@
 2012-08-26  Pavel Feldman  <[email protected]>
 
+        Web Inspector: make ConsoleView listen to the _javascript_ContextManager
+        https://bugs.webkit.org/show_bug.cgi?id=94940
+
+        Reviewed by Vsevolod Vlasov.
+
+        Otherwise, model is pushing data into the UI.
+
+        * inspector/front-end/ConsoleMessage.js:
+        (WebInspector.ConsoleMessageImpl.prototype.clone):
+        * inspector/front-end/ConsoleView.js:
+        (WebInspector.ConsoleView.prototype._contextAdded):
+        (WebInspector.ConsoleView.prototype._addContext):
+        (WebInspector.ConsoleView.prototype._contextRemoved):
+        * inspector/front-end/_javascript_ContextManager.js:
+        (WebInspector._javascript_ContextManager):
+        (WebInspector._javascript_ContextManager.prototype.contexts):
+        (WebInspector._javascript_ContextManager.prototype._frameAdded):
+        (WebInspector._javascript_ContextManager.prototype._frameDetached):
+        * inspector/front-end/ParsedURL.js:
+        (WebInspector.ParsedURL.completeURL):
+        (WebInspector.TextEditorDelegateForSourceFrame.prototype.createLink):
+        * inspector/front-end/inspector.js:
+
+2012-08-26  Pavel Feldman  <[email protected]>
+
         Web Inspector: provide "show function definition" and "reveal in elements panel" using context menu provider.
         https://bugs.webkit.org/show_bug.cgi?id=94932
 

Modified: trunk/Source/WebCore/inspector/front-end/ConsoleMessage.js (126708 => 126709)


--- trunk/Source/WebCore/inspector/front-end/ConsoleMessage.js	2012-08-26 18:23:54 UTC (rev 126708)
+++ trunk/Source/WebCore/inspector/front-end/ConsoleMessage.js	2012-08-26 18:42:41 UTC (rev 126709)
@@ -715,7 +715,7 @@
      */
     clone: function()
     {
-        return WebInspector.ConsoleMessage.create(this.source, this.level, this._messageText, this.type, this.url, this.line, this.repeatCount, this._parameters, this._stackTrace, this._requestId, this._isOutdated);
+        return WebInspector.ConsoleMessage.create(this.source, this.level, this._messageText, this.type, this.url, this.line, this.repeatCount, this._parameters, this._stackTrace, this._request ? this._request.requestId : undefined, this._isOutdated);
     }
 }
 

Modified: trunk/Source/WebCore/inspector/front-end/ConsoleView.js (126708 => 126709)


--- trunk/Source/WebCore/inspector/front-end/ConsoleView.js	2012-08-26 18:23:54 UTC (rev 126708)
+++ trunk/Source/WebCore/inspector/front-end/ConsoleView.js	2012-08-26 18:42:41 UTC (rev 126709)
@@ -117,6 +117,10 @@
     this.prompt.attach(this.promptElement);
     this.prompt.proxyElement.addEventListener("keydown", this._promptKeyDown.bind(this), false);
     this.prompt.setHistoryData(WebInspector.settings.consoleHistory.get());
+
+    WebInspector._javascript_ContextManager.contexts().forEach(this._addContext, this);
+    WebInspector._javascript_ContextManager.addEventListener(WebInspector._javascript_ContextManager.Events.FrameContextAdded, this._contextAdded, this);
+    WebInspector._javascript_ContextManager.addEventListener(WebInspector._javascript_ContextManager.Events.FrameContextRemoved, this._contextRemoved, this);
 }
 
 WebInspector.ConsoleView.Events = {
@@ -130,8 +134,20 @@
         return [this._clearConsoleButton.element, this._contextSelector.element, this._isolatedWorldSelector.element, this._filterBarElement];
     },
 
-    addContext: function(context)
+    /**
+     * @param {WebInspector.Event} event
+     */
+    _contextAdded: function(event)
     {
+        var context = /** @type {WebInspector.FrameEvaluationContext} */ event.data;
+        this._addContext(context);
+    },
+
+    /**
+     * @param {WebInspector.FrameEvaluationContext} context
+     */
+    _addContext: function(context)
+    {
         var option = document.createElement("option");
         option.text = context.displayName;
         option.title = context.url;
@@ -143,8 +159,12 @@
         this._updateIsolatedWorldSelector();
     },
 
-    removeContext: function(context)
+    /**
+     * @param {WebInspector.Event} event
+     */
+    _contextRemoved: function(event)
     {
+        var context = /** @type {WebInspector.FrameEvaluationContext} */ event.data;
         this._contextSelector.removeOption(context._consoleOption);
         this._updateIsolatedWorldSelector();
     },
@@ -361,6 +381,9 @@
         delete this._scrollIntoViewTimer;
     },
 
+    /**
+     * @param {WebInspector.Event} event
+     */
     _consoleMessageAdded: function(event)
     {
         this._appendConsoleMessage(event.data);

Modified: trunk/Source/WebCore/inspector/front-end/_javascript_ContextManager.js (126708 => 126709)


--- trunk/Source/WebCore/inspector/front-end/_javascript_ContextManager.js	2012-08-26 18:23:54 UTC (rev 126708)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_ContextManager.js	2012-08-26 18:42:41 UTC (rev 126709)
@@ -31,19 +31,32 @@
 /**
  * @constructor
  * @extends {WebInspector.Object}
+ * @param {WebInspector.ResourceTreeModel} resourceTreeModel
  */
-WebInspector._javascript_ContextManager = function(resourceTreeModel, consoleView)
+WebInspector._javascript_ContextManager = function(resourceTreeModel)
 {
     resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameAdded, this._frameAdded, this);
     resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, this._frameNavigated, this);
     resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameDetached, this._frameDetached, this);
     resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded, this._didLoadCachedResources, this);
-    this._consoleView = consoleView;
     this._frameIdToContext = {};
 }
 
+WebInspector._javascript_ContextManager.Events = {
+    FrameContextAdded: "FrameContextAdded",
+    FrameContextRemoved: "FrameContextRemoved",
+}
+
 WebInspector._javascript_ContextManager.prototype = {
     /**
+     * @return {Array.<WebInspector.FrameEvaluationContext>}
+     */
+    contexts: function()
+    {
+        return Object.values(this._frameIdToContext);
+    },
+
+    /**
      * @param {WebInspector.ResourceTreeFrame} frame
      * @param {string} securityOrigin
      */
@@ -58,7 +71,7 @@
         var frame = event.data;
         var context = new WebInspector.FrameEvaluationContext(frame);
         this._frameIdToContext[frame.id] = context;
-        this._consoleView.addContext(context);
+        this.dispatchEventToListeners(WebInspector._javascript_ContextManager.Events.FrameContextAdded, context);
     },
 
     _frameNavigated: function(event)
@@ -75,7 +88,7 @@
         var context = this._frameIdToContext[frame.id];
         if (!context)
             return;
-        this._consoleView.removeContext(context);
+        this.dispatchEventToListeners(WebInspector._javascript_ContextManager.Events.FrameContextRemoved, context);
         delete this._frameIdToContext[frame.id];
     },
 

Modified: trunk/Source/WebCore/inspector/front-end/ParsedURL.js (126708 => 126709)


--- trunk/Source/WebCore/inspector/front-end/ParsedURL.js	2012-08-26 18:23:54 UTC (rev 126708)
+++ trunk/Source/WebCore/inspector/front-end/ParsedURL.js	2012-08-26 18:42:41 UTC (rev 126709)
@@ -98,10 +98,8 @@
     if (href) {
         // Return special URLs as-is.
         var trimmedHref = href.trim();
-        if (trimmedHref.startsWith("data:") || trimmedHref.startsWith("blob:"))
+        if (trimmedHref.startsWith("data:") || trimmedHref.startsWith("blob:") || trimmedHref.startsWith("_javascript_:"))
             return href;
-        if (!sanitizeHref(trimmedHref))
-            return null; // Sanitize _javascript_ URLs from content
 
         // Return absolute URLs as-is.
         var parsedHref = trimmedHref.asParsedURL();

Modified: trunk/Source/WebCore/inspector/front-end/SourceFrame.js (126708 => 126709)


--- trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2012-08-26 18:23:54 UTC (rev 126708)
+++ trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2012-08-26 18:42:41 UTC (rev 126709)
@@ -704,10 +704,8 @@
      */
     createLink: function(hrefValue, isExternal)
     {
-        var targetLocation = hrefValue;
-        if (this._sourceFrame._url && hrefValue && hrefValue.indexOf("://") === -1)
-            targetLocation = WebInspector.ParsedURL.completeURL(this._sourceFrame._url, hrefValue);
-        return WebInspector.linkifyURLAsNode(targetLocation, hrefValue, undefined, isExternal);
+        var targetLocation = WebInspector.ParsedURL.completeURL(this._sourceFrame._url, hrefValue);
+        return WebInspector.linkifyURLAsNode(targetLocation || hrefValue, hrefValue, undefined, isExternal);
     }
 }
 

Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (126708 => 126709)


--- trunk/Source/WebCore/inspector/front-end/inspector.js	2012-08-26 18:23:54 UTC (rev 126708)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js	2012-08-26 18:42:41 UTC (rev 126709)
@@ -484,7 +484,6 @@
     WebInspector.CSSCompletions.requestCSSNameCompletions();
 
     this.drawer = new WebInspector.Drawer();
-    this.consoleView = new WebInspector.ConsoleView(WebInspector.WorkerManager.isWorkerFrontend());
 
     this.networkManager = new WebInspector.NetworkManager();
     this.resourceTreeModel = new WebInspector.ResourceTreeModel(this.networkManager);
@@ -492,10 +491,11 @@
     this.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this);
     this.networkLog = new WebInspector.NetworkLog();
     this.domAgent = new WebInspector.DOMAgent();
-    this._javascript_ContextManager = new WebInspector._javascript_ContextManager(this.resourceTreeModel, this.consoleView);
-
+    this._javascript_ContextManager = new WebInspector._javascript_ContextManager(this.resourceTreeModel);
     this.scriptSnippetModel = new WebInspector.ScriptSnippetModel();
 
+    this.consoleView = new WebInspector.ConsoleView(WebInspector.WorkerManager.isWorkerFrontend());
+
     InspectorBackend.registerInspectorDispatcher(this);
 
     this.cssModel = new WebInspector.CSSStyleModel();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to