Title: [143443] trunk
Revision
143443
Author
[email protected]
Date
2013-02-20 03:01:27 -0800 (Wed, 20 Feb 2013)

Log Message

Web Inspector: Introduce SecurityOriginAdded and SecurityOriginRemoved events into ResourceTreeModel
https://bugs.webkit.org/show_bug.cgi?id=110232

Reviewed by Vsevolod Vlasov.

Source/WebCore:

* inspector/front-end/ResourceTreeModel.js:
(WebInspector.ResourceTreeModel):
(WebInspector.ResourceTreeModel.prototype._addFrame):
(WebInspector.ResourceTreeModel.prototype._addSecurityOrigin): Added.
(WebInspector.ResourceTreeModel.prototype._removeSecurityOrigin): Added.
(WebInspector.ResourceTreeModel.prototype._handleMainFrameDetached): Added.
(WebInspector.ResourceTreeModel.prototype._frameNavigated):
(WebInspector.ResourceTreeModel.prototype._frameDetached):

LayoutTests:

* http/tests/inspector/resource-tree/resource-tree-events-expected.txt:
* http/tests/inspector/resource-tree/resource-tree-events.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (143442 => 143443)


--- trunk/LayoutTests/ChangeLog	2013-02-20 10:01:33 UTC (rev 143442)
+++ trunk/LayoutTests/ChangeLog	2013-02-20 11:01:27 UTC (rev 143443)
@@ -1,3 +1,13 @@
+2013-02-20  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: Introduce SecurityOriginAdded and SecurityOriginRemoved events into ResourceTreeModel
+        https://bugs.webkit.org/show_bug.cgi?id=110232
+
+        Reviewed by Vsevolod Vlasov.
+
+        * http/tests/inspector/resource-tree/resource-tree-events-expected.txt:
+        * http/tests/inspector/resource-tree/resource-tree-events.html:
+
 2013-02-20  Dominik Röttsches  <[email protected]>
 
         [EFL] Unreviewed gardening.

Modified: trunk/LayoutTests/http/tests/inspector/resource-tree/resource-tree-events-expected.txt (143442 => 143443)


--- trunk/LayoutTests/http/tests/inspector/resource-tree/resource-tree-events-expected.txt	2013-02-20 10:01:33 UTC (rev 143442)
+++ trunk/LayoutTests/http/tests/inspector/resource-tree/resource-tree-events-expected.txt	2013-02-20 11:01:27 UTC (rev 143443)
@@ -4,15 +4,25 @@
 Navigating child frame 1
     FrameAdded : child1
     FrameNavigated : child1
+    SecurityOriginAdded : http://frame/child1.html
+Navigating child frame 1 to a different URL
+    SecurityOriginRemoved : http://frame/child1.html
+    FrameNavigated : child1
+    SecurityOriginAdded : http://frame/child1-new.html
 Navigating child frame 2
     FrameAdded : child2
     FrameNavigated : child2
+    SecurityOriginAdded : http://frame/child2.html
 Detaching child frame 1
+    SecurityOriginRemoved : http://frame/child1-new.html
     FrameDetached : child1
 Navigating root frame
+    SecurityOriginRemoved : http://frame/child2.html
+    SecurityOriginRemoved : http://frame/root1.html
     FrameDetached : child2
     FrameDetached : root1
     FrameAdded : root2
     FrameNavigated : root2
     MainFrameNavigated : root2
+    SecurityOriginAdded : http://frame/root2.html
 

Modified: trunk/LayoutTests/http/tests/inspector/resource-tree/resource-tree-events.html (143442 => 143443)


--- trunk/LayoutTests/http/tests/inspector/resource-tree/resource-tree-events.html	2013-02-20 10:01:33 UTC (rev 143442)
+++ trunk/LayoutTests/http/tests/inspector/resource-tree/resource-tree-events.html	2013-02-20 11:01:27 UTC (rev 143443)
@@ -27,6 +27,11 @@
                 var frame = event.data;
                 InspectorTest.addResult("    " + eventName + " : " + frame.id);
                 break;
+            case "SecurityOriginAdded":
+            case "SecurityOriginRemoved":
+                var securityOrigin = event.data;
+                InspectorTest.addResult("    " + eventName + " : " + securityOrigin);
+                break;
             default:
             }
             
@@ -34,6 +39,8 @@
 
         InspectorTest.addResult("Navigating child frame 1");
         WebInspector.resourceTreeModel._frameNavigated(createFramePayload("child1", "root1"));
+        InspectorTest.addResult("Navigating child frame 1 to a different URL");
+        WebInspector.resourceTreeModel._frameNavigated(createFramePayload("child1", "root1", "child1-new"));
         InspectorTest.addResult("Navigating child frame 2");
         WebInspector.resourceTreeModel._frameNavigated(createFramePayload("child2", "root1"));
         InspectorTest.addResult("Detaching child frame 1");
@@ -44,14 +51,15 @@
         InspectorTest.completeTest();
     }
 
-    function createFramePayload(id, parentId)
+    function createFramePayload(id, parentId, name)
     {
         var framePayload = {};
         framePayload.id = id;
         framePayload.parentId = parentId || "";
         framePayload.loaderId = "loader-" + id;
         framePayload.name = "frame-" + id;
-        framePayload.url = "" + id + ".html";
+        framePayload.url = "" + (name || id) + ".html";
+        framePayload.securityOrigin = framePayload.url;
         framePayload.mimeType = "text/html";
         return framePayload;
     }

Modified: trunk/Source/WebCore/ChangeLog (143442 => 143443)


--- trunk/Source/WebCore/ChangeLog	2013-02-20 10:01:33 UTC (rev 143442)
+++ trunk/Source/WebCore/ChangeLog	2013-02-20 11:01:27 UTC (rev 143443)
@@ -1,3 +1,19 @@
+2013-02-20  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: Introduce SecurityOriginAdded and SecurityOriginRemoved events into ResourceTreeModel
+        https://bugs.webkit.org/show_bug.cgi?id=110232
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/front-end/ResourceTreeModel.js:
+        (WebInspector.ResourceTreeModel):
+        (WebInspector.ResourceTreeModel.prototype._addFrame):
+        (WebInspector.ResourceTreeModel.prototype._addSecurityOrigin): Added.
+        (WebInspector.ResourceTreeModel.prototype._removeSecurityOrigin): Added.
+        (WebInspector.ResourceTreeModel.prototype._handleMainFrameDetached): Added.
+        (WebInspector.ResourceTreeModel.prototype._frameNavigated):
+        (WebInspector.ResourceTreeModel.prototype._frameDetached):
+
 2013-02-20  Dan Carney  <[email protected]>
 
         [v8] ScriptValue has dangerous copy semantics

Modified: trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js (143442 => 143443)


--- trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js	2013-02-20 10:01:33 UTC (rev 143442)
+++ trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js	2013-02-20 11:01:27 UTC (rev 143443)
@@ -50,6 +50,7 @@
     InspectorBackend.registerPageDispatcher(new WebInspector.PageDispatcher(this));
 
     this._pendingConsoleMessages = {};
+    this._securityOriginFrameCount = {};
 }
 
 WebInspector.ResourceTreeModel.EventTypes = {
@@ -63,7 +64,9 @@
     CachedResourcesLoaded: "CachedResourcesLoaded",
     DOMContentLoaded: "DOMContentLoaded",
     OnLoad: "OnLoad",
-    InspectedURLChanged: "InspectedURLChanged"
+    InspectedURLChanged: "InspectedURLChanged",
+    SecurityOriginAdded: "SecurityOriginAdded",
+    SecurityOriginRemoved: "SecurityOriginRemoved"
 }
 
 WebInspector.ResourceTreeModel.prototype = {
@@ -102,18 +105,66 @@
 
     /**
      * @param {WebInspector.ResourceTreeFrame} frame
+     * @param {boolean=} aboutToNavigate
      */
-    _addFrame: function(frame)
+    _addFrame: function(frame, aboutToNavigate)
     {
         this._frames[frame.id] = frame;
         if (frame.isMainFrame())
             this.mainFrame = frame;
         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameAdded, frame);
+        if (!aboutToNavigate)
+            this._addSecurityOrigin(frame.securityOrigin);
         if (frame.isMainFrame())
             this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.MainFrameCreatedOrNavigated, frame);
     },
 
     /**
+     * @param {string} securityOrigin
+     */
+    _addSecurityOrigin: function(securityOrigin)
+    {
+        if (!this._securityOriginFrameCount[securityOrigin]) {
+            this._securityOriginFrameCount[securityOrigin] = 1;
+            this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.SecurityOriginAdded, securityOrigin);
+            return;
+        }
+        this._securityOriginFrameCount[securityOrigin] += 1;
+    },
+
+    /**
+     * @param {string} securityOrigin
+     */
+    _removeSecurityOrigin: function(securityOrigin)
+    {
+        console.assert(this._securityOriginFrameCount[securityOrigin]);
+        if (this._securityOriginFrameCount[securityOrigin] === 1) {
+            delete this._securityOriginFrameCount[securityOrigin];
+            this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.SecurityOriginRemoved, securityOrigin);
+            return;
+        }
+        this._securityOriginFrameCount[securityOrigin] -= 1;
+    },
+
+    /**
+     * @param {WebInspector.ResourceTreeFrame} mainFrame
+     */
+    _handleMainFrameDetached: function(mainFrame)
+    {
+        /**
+         * @param {WebInspector.ResourceTreeFrame} frame
+         */
+        function removeOriginForFrame(frame)
+        {
+            for (var i = 0; i < frame.childFrames.length; ++i)
+                removeOriginForFrame.call(this, frame.childFrames[i]);
+            if (!frame.isMainFrame())
+                this._removeSecurityOrigin(frame.securityOrigin);
+        }
+        removeOriginForFrame.call(this, WebInspector.resourceTreeModel.mainFrame);
+    },
+
+    /**
      * @param {PageAgent.Frame} framePayload
      */
     _frameNavigated: function(framePayload)
@@ -122,18 +173,23 @@
         if (!this._cachedResourcesProcessed)
             return;
         var frame = this._frames[framePayload.id];
+        var addedOrigin;
         if (frame) {
             // Navigation within existing frame.
+            this._removeSecurityOrigin(frame.securityOrigin);
             frame._navigate(framePayload);
+            addedOrigin = frame.securityOrigin;
         } else {
             // Either a new frame or a main frame navigation to the new backend process. 
             var parentFrame = this._frames[framePayload.parentId];
             frame = new WebInspector.ResourceTreeFrame(this, parentFrame, framePayload);
             if (frame.isMainFrame() && this.mainFrame) {
+                this._handleMainFrameDetached(this.mainFrame);
                 // Definitely a navigation to the new backend process.
                 this._frameDetached(this.mainFrame.id);
             }
-            this._addFrame(frame);
+            this._addFrame(frame, true);
+            addedOrigin = frame.securityOrigin;
         }
 
         if (frame.isMainFrame())
@@ -144,6 +200,8 @@
             this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, frame);
             this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.MainFrameCreatedOrNavigated, frame);
         }
+        if (addedOrigin)
+            this._addSecurityOrigin(addedOrigin);
 
         // Fill frame with retained resources (the ones loaded using new loader).
         var resources = frame.resources();
@@ -167,6 +225,7 @@
         if (!frame)
             return;
 
+        this._removeSecurityOrigin(frame.securityOrigin);
         if (frame.parentFrame)
             frame.parentFrame._removeChildFrame(frame);
         else
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to