2011-04-06 Andrey Kosyakov <caseq@chromium.org>
authorcaseq@chromium.org <caseq@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Apr 2011 08:24:28 +0000 (08:24 +0000)
committercaseq@chromium.org <caseq@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Apr 2011 08:24:28 +0000 (08:24 +0000)
        Reviewed by Yury Semikhatsky.

        Web Inspector: [Extensions API] remove inspectedPage.* events
        https://bugs.webkit.org/show_bug.cgi?id=57763

        - Removed webInspector.inspectedPage.* events
        - moved onNavigated to webInspector.resources

        * inspector/front-end/ExtensionAPI.js:
        (WebInspector.injectedExtensionAPI):
        (WebInspector.injectedExtensionAPI.InspectedWindow):
        * inspector/front-end/ExtensionAPISchema.json:
        * inspector/front-end/ExtensionServer.js:
        (WebInspector.ExtensionServer.prototype.notifyInspectedURLChanged):
        * inspector/front-end/inspector.js:
        (WebInspector.domContentEventFired):
        (WebInspector.loadEventFired):
        (WebInspector.inspectedURLChanged):

2011-04-06  Andrey Kosyakov  <caseq@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: [Extensions API] remove inspectedPage.* events
        https://bugs.webkit.org/show_bug.cgi?id=57763

        - Removed webInspector.inspectedPage.* events
        - moved onNavigated to webInspector.resources

        * http/tests/inspector/extensions-test.js:
        (initialize_ExtensionsTest.runWhenPageLoads):
        * http/tests/inspector/inspector-test.js:
        (initialize_InspectorTest.InspectorTest.runWhenPageLoads.chainedCallback):
        (initialize_InspectorTest.InspectorTest.runWhenPageLoads):
        * inspector/extensions/extensions-api-expected.txt:
        * inspector/extensions/extensions-events-expected.txt:
        * inspector/extensions/extensions-events.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83033 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/extensions-test.js
LayoutTests/http/tests/inspector/inspector-test.js
LayoutTests/inspector/extensions/extensions-api-expected.txt
LayoutTests/inspector/extensions/extensions-events-expected.txt
LayoutTests/inspector/extensions/extensions-events.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/ExtensionAPI.js
Source/WebCore/inspector/front-end/ExtensionAPISchema.json
Source/WebCore/inspector/front-end/ExtensionServer.js
Source/WebCore/inspector/front-end/inspector.js

index e54d81a..c48c0cf 100644 (file)
@@ -1,3 +1,22 @@
+2011-04-05  Andrey Kosyakov  <caseq@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: [Extensions API] remove inspectedPage.* events
+        https://bugs.webkit.org/show_bug.cgi?id=57763
+
+        - Removed webInspector.inspectedPage.* events
+        - moved onNavigated to webInspector.resources
+
+        * http/tests/inspector/extensions-test.js:
+        (initialize_ExtensionsTest.runWhenPageLoads):
+        * http/tests/inspector/inspector-test.js:
+        (initialize_InspectorTest.InspectorTest.runWhenPageLoads.chainedCallback):
+        (initialize_InspectorTest.InspectorTest.runWhenPageLoads):
+        * inspector/extensions/extensions-api-expected.txt:
+        * inspector/extensions/extensions-events-expected.txt:
+        * inspector/extensions/extensions-events.html:
+
 2011-04-05  Mikhail Naganov  <mnaganov@chromium.org>
 
         Reviewed by Pavel Feldman.
index ecac9a3..ff61a21 100644 (file)
@@ -84,6 +84,14 @@ function reloadPage(data, port)
 }
 InspectorTest.dispatchOnMessage("reload", reloadPage, true);
 
+function runWhenPageLoads(data, port)
+{
+    InspectorTest.runWhenPageLoads(function() {
+        port.postMessage("");
+    });
+}
+InspectorTest.dispatchOnMessage("run-when-page-loads", runWhenPageLoads, true);
+
 }
 
 var test = function()
index 7c68b20..b7dfbb5 100644 (file)
@@ -151,6 +151,18 @@ InspectorTest.pageReloaded = function()
     }
 }
 
+InspectorTest.runWhenPageLoads = function(callback)
+{
+    var oldCallback = InspectorTest._reloadPageCallback;
+    function chainedCallback()
+    {
+        if (oldCallback)
+            oldCallback();
+        callback();
+    }
+    InspectorTest._reloadPageCallback = InspectorTest.safeWrap(chainedCallback);
+}
+
 InspectorTest.runAfterPendingDispatches = function(callback)
 {
     callback = InspectorTest.safeWrap(callback);
index 5377d36..5f295f7 100644 (file)
@@ -8,18 +8,6 @@ RUNNING TEST: extension_testAPI
         addCategory : <function>
     }
     inspectedWindow : {
-        onDOMContentLoaded : {
-            addListener : <function>
-            removeListener : <function>
-        }
-        onLoaded : {
-            addListener : <function>
-            removeListener : <function>
-        }
-        onNavigated : {
-            addListener : <function>
-            removeListener : <function>
-        }
         reload : <function>
         eval : <function>
     }
@@ -46,6 +34,10 @@ RUNNING TEST: extension_testAPI
             addListener : <function>
             removeListener : <function>
         }
+        onNavigated : {
+            addListener : <function>
+            removeListener : <function>
+        }
         getHAR : <function>
         addRequestHeaders : <function>
     }
index e14fc7e..6b7d22c 100644 (file)
@@ -2,14 +2,15 @@ Tests WebInspector extension API
 
 Started extension.
 Running tests...
+RUNNING TEST: extension_testOnNavigated
+Page reloaded.
+Page reloaded.
+Navigated to: extensions-events.html?navigated
+Navigated to: extensions-events.html
 RUNNING TEST: extension_testOnResourceFinished
 onFinished fired
 RUNNING TEST: extension_testOnSelectionChanged
 onSelectionChanged fired
-RUNNING TEST: extension_testPageLoadEvents
-Page reloaded.
-onDOMContentLoaded fired: number
-onLoaded fired: number
 RUNNING TEST: extension_testPanelShowHide
 Got onHidden event for panel elements
 Got onShown event for panel extension
index 8dc99dd..404c0b8 100644 (file)
@@ -28,32 +28,39 @@ function extension_testOnResourceFinished(nextTest)
     webInspector.inspectedWindow.eval("var xhr = new XMLHttpRequest(); xhr.open('GET', '" + location.href + "', false); xhr.send(null);");
 }
 
-function extension_testPageLoadEvents(nextTest)
+function extension_testOnNavigated(nextTest)
 {
-    var queuedOutput = [];
+    var urls = [];
+    var loadCount = 0;
 
-    // Logging on onLoaded is tricky due to race conditions with output("Page reloaded") in page initialization code.
-    // So only log when we're sure all handlers are called and reload is done.
-    function queueOutputAndContinue(message)
+    function onLoad()
     {
-        queuedOutput.push(message);
-        if (queuedOutput.length != 3)
+        ++loadCount;
+        processEvent();
+    }
+    function processEvent()
+    {
+        if (loadCount !== urls.length)
             return;
-        for (i = 0; i < queuedOutput.length; ++i) {
-            if (queuedOutput[i])
-                output(queuedOutput[i]);
+        if (loadCount === 1) {
+            dispatchOnFrontend({ command: "run-when-page-loads" }, onLoad);
+            webInspector.inspectedWindow.eval("location.href = location.origin + location.pathname");
+        }
+        else {
+            webInspector.resources.onNavigated.removeListener(onNavigated);
+            for (var i = 0; i < urls.length; ++i)
+                output("Navigated to: " + urls[i]);
+            nextTest();
         }
-        nextTest();
     }
-
-    webInspector.inspectedWindow.onDOMContentLoaded.addListener(function(time) {
-        queueOutputAndContinue("onDOMContentLoaded fired: " + typeof time);
-    });
-
-    webInspector.inspectedWindow.onLoaded.addListener(function(time) {
-        queueOutputAndContinue("onLoaded fired: " + typeof time);
-    });
-    dispatchOnFrontend({ command: "reload" }, queueOutputAndContinue);
+    function onNavigated(url)
+    {
+        urls.push(url.replace(/^(.*\/)*/, ""));
+        processEvent();
+    }
+    webInspector.resources.onNavigated.addListener(onNavigated);
+    dispatchOnFrontend({ command: "run-when-page-loads" }, onLoad);
+    webInspector.inspectedWindow.eval("location.href = location.href + '?navigated'");
 }
 
 function extension_testPanelShowHide(nextTest)
index 42fe7c3..775f75c 100644 (file)
@@ -1,3 +1,24 @@
+2011-04-06  Andrey Kosyakov  <caseq@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: [Extensions API] remove inspectedPage.* events
+        https://bugs.webkit.org/show_bug.cgi?id=57763
+
+        - Removed webInspector.inspectedPage.* events
+        - moved onNavigated to webInspector.resources
+
+        * inspector/front-end/ExtensionAPI.js:
+        (WebInspector.injectedExtensionAPI):
+        (WebInspector.injectedExtensionAPI.InspectedWindow):
+        * inspector/front-end/ExtensionAPISchema.json:
+        * inspector/front-end/ExtensionServer.js:
+        (WebInspector.ExtensionServer.prototype.notifyInspectedURLChanged):
+        * inspector/front-end/inspector.js:
+        (WebInspector.domContentEventFired):
+        (WebInspector.loadEventFired):
+        (WebInspector.inspectedURLChanged):
+
 2011-04-06  Joseph Pecoraro  <joepeck@webkit.org>
 
         Reviewed by Antti Koivisto.
index bab5f18..940e340 100644 (file)
@@ -111,6 +111,7 @@ function Resources()
         this._fire(resource);
     }
     this.onFinished = new EventSink("resource-finished", resourceDispatch);
+    this.onNavigated = new EventSink("inspectedURLChanged");
 }
 
 Resources.prototype = {
@@ -356,9 +357,6 @@ AuditResultNode.prototype = {
 
 function InspectedWindow()
 {
-    this.onDOMContentLoaded = new EventSink("inspectedPageDOMContentLoaded");
-    this.onLoaded = new EventSink("inspectedPageLoaded");
-    this.onNavigated = new EventSink("inspectedURLChanged");
 }
 
 InspectedWindow.prototype = {
index 526fd41..c4c8358 100755 (executable)
             "name": "pageURL",
             "type": "string",
             "description": "An URL of the page that represents this panel."
+          },
+          {
+            "name": "callback",
+            "type": "function",
+            "description": "A function that is called upon request completion.",
+            "parameters": [
+              {
+                "name": "panel",
+                "description": "An ExtensionPanel object representing the created panel.",
+                "$ref": "ExtensionPanel"
+              }
+            ]
           }
-        ],
-        "returns" : {
-          "$ref": "ExtensionPanel",
-          "description": "A panel that was created."
-        }
+        ]
       }
     ]
   },
         "parameters": [
           { "name": "resource", "$ref": "Resource" }
         ]
+      },
+      {
+        "name": "onNavigation",
+        "type": "function",
+        "description": "Fired when an inspected window navigates to a new URL.",
+        "parameters": [
+          {
+            "name": "url",
+            "type": "stirng",
+            "description": "URL of the new page."
+          }
+        ]
       }
     ]
   },
index d520fd9..2c95ef0 100644 (file)
@@ -79,19 +79,9 @@ WebInspector.ExtensionServer.prototype = {
         this._postNotification("panel-hidden-" + panelId);
     },
 
-    notifyPageLoaded: function(milliseconds)
+    notifyInspectedURLChanged: function(url)
     {
-        this._postNotification("inspectedPageLoaded", milliseconds);
-    },
-
-    notifyPageDOMContentLoaded: function(milliseconds)
-    {
-        this._postNotification("inspectedPageDOMContentLoaded", milliseconds);
-    },
-
-    notifyInspectedURLChanged: function()
-    {
-        this._postNotification("inspectedURLChanged");
+        this._postNotification("inspectedURLChanged", url);
     },
 
     notifyInspectorReset: function()
index 536a806..be7cf3b 100644 (file)
@@ -989,7 +989,6 @@ WebInspector.domContentEventFired = function(time)
     this.panels.audits.mainResourceDOMContentTime = time;
     if (this.panels.network)
         this.panels.network.mainResourceDOMContentTime = time;
-    this.extensionServer.notifyPageDOMContentLoaded((time - WebInspector.mainResource.startTime) * 1000);
     this.mainResourceDOMContentTime = time;
 }
 
@@ -998,7 +997,6 @@ WebInspector.loadEventFired = function(time)
     this.panels.audits.mainResourceLoadTime = time;
     this.panels.network.mainResourceLoadTime = time;
     this.panels.resources.loadEventFired();
-    this.extensionServer.notifyPageLoaded((time - WebInspector.mainResource.startTime) * 1000);
     this.mainResourceLoadTime = time;
 }
 
@@ -1038,7 +1036,7 @@ WebInspector.inspectedURLChanged = function(url)
 {
     InspectorFrontendHost.inspectedURLChanged(url);
     this.settings.inspectedURLChanged(url);
-    this.extensionServer.notifyInspectedURLChanged();
+    this.extensionServer.notifyInspectedURLChanged(url);
 }
 
 WebInspector.didCreateWorker = function()