[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

yurys at chromium.org yurys at chromium.org
Wed Dec 22 12:17:35 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 31673e3040831504729426e5221a72bb3e8ff746
Author: yurys at chromium.org <yurys at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 18 13:27:26 2010 +0000

    2010-08-18  Pavel Podivilov  <podivilov at chromium.org>
    
            Reviewed by Yury Semikhatsky.
    
            Web Inspector: inspector tests should be frontend-driven
    
            * http/tests/inspector/inspector-test2.js: Added.
            (initializeInspectorTest):
            (initializeInspectorTest.):
            ():
            (completeTest):
            (dumpArray):
            (dumpObject):
            (output):
            (didEvaluateForTestInFrontend):
            * inspector/debugger-breakpoints-not-activated-on-reload-expected.txt:
            * inspector/debugger-breakpoints-not-activated-on-reload.html:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65606 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index fa0ab45..054e986 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2010-08-18  Pavel Podivilov  <podivilov at chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: inspector tests should be frontend-driven
+
+        * http/tests/inspector/inspector-test2.js: Added.
+        (initializeInspectorTest):
+        (initializeInspectorTest.):
+        ():
+        (completeTest):
+        (dumpArray):
+        (dumpObject):
+        (output):
+        (didEvaluateForTestInFrontend):
+        * inspector/debugger-breakpoints-not-activated-on-reload-expected.txt:
+        * inspector/debugger-breakpoints-not-activated-on-reload.html:
+
 2010-08-18  Yuta Kitamura  <yutak at chromium.org>
 
         Unreviewed, test expectation update.
diff --git a/LayoutTests/http/tests/inspector/inspector-test2.js b/LayoutTests/http/tests/inspector/inspector-test2.js
new file mode 100644
index 0000000..d4580ae
--- /dev/null
+++ b/LayoutTests/http/tests/inspector/inspector-test2.js
@@ -0,0 +1,216 @@
+var initializeInspectorTest = (function(completeTestCallId) {
+
+var results = [];
+
+InspectorTest.completeTest = function()
+{
+    InspectorBackend.didEvaluateForTestInFrontend(completeTestCallId, JSON.stringify(results));
+};
+
+InspectorTest.evaluateInConsole = function(code, callback)
+{
+    WebInspector.console.visible = true;
+    WebInspector.console.prompt.text = code;
+    WebInspector.console.promptElement.dispatchEvent(createKeyEvent("Enter"));
+
+    addSniffer(WebInspector.ConsoleView.prototype, "addMessage",
+        function(commandResult) {
+            if (callback)
+                callback(commandResult.toMessageElement().textContent);
+        });
+};
+
+InspectorTest.addResult = function(text)
+{
+    results.push(text);
+};
+
+InspectorTest.reloadPage = function(callback)
+{
+    InspectorBackend.reloadPage();
+    addSniffer(WebInspector, "reset", callback);
+};
+
+InspectorTest.ensureDebuggerEnabled = function(callback)
+{
+    if (WebInspector.panels.scripts._debuggerEnabled)
+        callback();
+    else {
+        addSniffer(WebInspector, "debuggerWasEnabled", callback);
+        WebInspector.panels.scripts._toggleDebugging(false);
+    }
+};
+
+InspectorTest.ensureDebuggerDisabled = function(callback)
+{
+    if (!WebInspector.panels.scripts._debuggerEnabled)
+        callback();
+    else {
+        addSniffer(WebInspector, "debuggerWasDisabled", callback);
+        WebInspector.panels.scripts._toggleDebugging(false);
+    }
+};
+
+InspectorTest.showScriptSource = function(scriptName, callback)
+{
+    function waitForAllScripts()
+    {
+        if (scriptsAreParsed([scriptName]))
+            showScriptSource(scriptName, callback);
+        else
+            addSniffer(WebInspector, "parsedScriptSource", waitForAllScripts);
+    }
+    waitForAllScripts();
+};
+
+function createKeyEvent(keyIdentifier)
+{
+    var evt = document.createEvent("KeyboardEvent");
+    evt.initKeyboardEvent("keydown", true, true, null, keyIdentifier, "");
+    return evt;
+}
+
+function addSniffer(receiver, methodName, override, opt_sticky)
+{
+    var original = receiver[methodName];
+    if (typeof original !== "function")
+        throw ("Cannot find method to override: " + methodName);
+    receiver[methodName] = function(var_args) {
+        try {
+            var result = original.apply(this, arguments);
+        } finally {
+            if (!opt_sticky)
+                receiver[methodName] = original;
+        }
+        // In case of exception the override won't be called.
+        try {
+            override.apply(this, arguments);
+        } catch (e) {
+            throw ("Exception in overriden method '" + methodName + "': " + e);
+        }
+        return result;
+    };
+}
+
+function scriptsAreParsed(scripts)
+{
+    var scriptSelect = document.getElementById("scripts-files");
+    var options = scriptSelect.options;
+
+    // Check that all the expected scripts are present.
+    for (var i = 0; i < scripts.length; i++) {
+        var found = false;
+        for (var j = 0; j < options.length; j++) {
+            if (options[j].text === scripts[i]) {
+                found = true;
+                break;
+            }
+        }
+        if (!found)
+            return false;
+    }
+    return true;
+};
+
+function showScriptSource(scriptName, callback)
+{
+    var scriptSelect = document.getElementById("scripts-files");
+    var options = scriptSelect.options;
+    var scriptsPanel = WebInspector.panels.scripts;
+
+    // Select page's script if it's not current option.
+    var scriptResource;
+    if (options[scriptSelect.selectedIndex].text === scriptName)
+        scriptResource = options[scriptSelect.selectedIndex].representedObject;
+    else {
+        var pageScriptIndex = -1;
+        for (var i = 0; i < options.length; i++) {
+            if (options[i].text === scriptName) {
+                pageScriptIndex = i;
+                break;
+            }
+        }
+        scriptResource = options[pageScriptIndex].representedObject;
+        scriptsPanel._showScriptOrResource(scriptResource);
+    }
+
+    var view = scriptsPanel.visibleView;
+    callback = callback.bind(null, view);
+    if (!view.sourceFrame._loaded)
+        addSniffer(view.sourceFrame, "setContent", callback);
+    else
+        callback();
+};
+
+});
+
+var runTestCallId = 0;
+var completeTestCallId = 1;
+
+function runTest()
+{
+    if (!window.layoutTestController)
+        return;
+
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+
+    var toEvaluate =
+        "if (!window.InspectorTest) {" +
+        "    var InspectorTest = {};" +
+        "    (" + initializeInspectorTest + ")(" + completeTestCallId + ");" +
+        "    WebInspector.showPanel('elements');" +
+        "    (" + test + ")();" +
+        "}";
+    layoutTestController.evaluateInWebInspector(runTestCallId, toEvaluate);
+}
+
+function didEvaluateForTestInFrontend(callId, result)
+{
+    if (callId !== completeTestCallId)
+        return;
+    dumpArray(JSON.parse(result));
+    layoutTestController.closeWebInspector();
+    setTimeout(function() {
+        layoutTestController.notifyDone();
+    }, 0);
+}
+
+function dumpArray(result)
+{
+    if (result instanceof Array) {
+        for (var i = 0; i < result.length; ++i)
+            output(result[i]);
+    } else
+        output(result);
+}
+
+function dumpObject(object, nondeterministicProps, prefix, firstLinePrefix)
+{
+    prefix = prefix || "";
+    firstLinePrefix = firstLinePrefix || prefix;
+    output(firstLinePrefix + "{");
+    for (var prop in object) {
+        var prefixWithName = prefix + "    " + prop + " : ";
+        var propValue = object[prop];
+        if (nondeterministicProps && prop in nondeterministicProps)
+            output(prefixWithName + "<" + typeof propValue + ">");
+        else if (typeof propValue === "object")
+            dumpObject(propValue, nondeterministicProps, prefix + "    ", prefixWithName);
+        else if (typeof propValue === "string")
+            output(prefixWithName + "\"" + propValue + "\"");
+        else
+            output(prefixWithName + propValue);
+    }
+    output(prefix + "}");
+}
+
+function output(text)
+{
+    var outputElement = document.createElement("div");
+    outputElement.id = "output";
+    outputElement.style.whiteSpace = "pre";
+    outputElement.appendChild(document.createTextNode(text));
+    outputElement.appendChild(document.createElement("br"));
+    document.body.appendChild(outputElement);
+}
diff --git a/LayoutTests/inspector/debugger-breakpoints-not-activated-on-reload-expected.txt b/LayoutTests/inspector/debugger-breakpoints-not-activated-on-reload-expected.txt
index 9afbb90..5bb06e4 100644
--- a/LayoutTests/inspector/debugger-breakpoints-not-activated-on-reload-expected.txt
+++ b/LayoutTests/inspector/debugger-breakpoints-not-activated-on-reload-expected.txt
@@ -1,7 +1,9 @@
 Tests that breakpoints are not activated on page reload.Bug 41461
 
 Debugger was enabled.
-Scripts were parsed.
-Breakpoints deactivated.
-Disabled debugger.
+Main resource was shown.
+Page reloaded.
+Main resource was shown.
+Breakpoints are deactivated.
+Debugger was disabled.
 
diff --git a/LayoutTests/inspector/debugger-breakpoints-not-activated-on-reload.html b/LayoutTests/inspector/debugger-breakpoints-not-activated-on-reload.html
index 562769c..0f602b7 100644
--- a/LayoutTests/inspector/debugger-breakpoints-not-activated-on-reload.html
+++ b/LayoutTests/inspector/debugger-breakpoints-not-activated-on-reload.html
@@ -1,7 +1,6 @@
 <html>
 <head>
-<script src="../http/tests/inspector/inspector-test.js"></script>
-<script src="../http/tests/inspector/debugger-test.js"></script>
+<script src="../http/tests/inspector/inspector-test2.js"></script>
 <script>
 
 function testFunction()
@@ -9,59 +8,57 @@ function testFunction()
     return 0;
 }
 
-function doit()
-{
-    evaluateInWebInspector("frontend_testBreakpointsNotActivatedOnReload", completeTest);
-}
-
-function frontend_testBreakpointsNotActivatedOnReload(testController)
+var test = function()
 {
     var testName = WebInspector.mainResource.url;
     testName = testName.substring(testName.lastIndexOf('/') + 1);
 
-    testController.waitUntilDone();
-
     WebInspector.showPanel("scripts");
-    frontend_ensureDebuggerEnabled(debuggerWasEnabledCallback);
+    InspectorTest.ensureDebuggerEnabled(ensureDebuggerEnabledCallback);
 
-    function debuggerWasEnabledCallback()
+    function ensureDebuggerEnabledCallback()
     {
-        testController.results.push("Debugger was enabled.");
-        frontend_waitUntilScriptsAreParsed([testName], waitUntilScriptsAreParsedCallback);
+        InspectorTest.addResult("Debugger was enabled.");
+        InspectorTest.showScriptSource(testName, showScriptSourceCallback);
     }
 
-    function waitUntilScriptsAreParsedCallback()
+    function showScriptSourceCallback(view)
     {
-        testController.results.push("Scripts were parsed.");
-        frontend_showScriptSource(testName, showScriptSourceCallback);
+        InspectorTest.addResult("Main resource was shown.");
+        view._addBreakpoint(8);
+        WebInspector.panels.scripts.toggleBreakpointsButton.element.click();
+        InspectorTest.reloadPage(reloadPageCallback);
     }
 
-    function showScriptSourceCallback(view)
+    function reloadPageCallback()
     {
-        if (!WebInspector.testBreakpointsNotActivatedOnReloadFlag) {
-            view._addBreakpoint(8);
-            WebInspector.panels.scripts.toggleBreakpointsButton.element.click();
-            InspectorBackend.reloadPage();
-            WebInspector.testBreakpointsNotActivatedOnReloadFlag = true;
-        } else {
-            if (!WebInspector.panels.scripts.breakpointsActivated)
-                testController.results.push("Breakpoints deactivated.");
-            else
-                testController.results.push("Error: breakpoints activated.");
-            frontend_completeDebuggerTest(testController);
-        }
+        InspectorTest.addResult("Page reloaded.");
+        InspectorTest.showScriptSource(testName, showScriptSourceAfterReloadCallback);
     }
-}
+
+    function showScriptSourceAfterReloadCallback(view)
+    {
+        InspectorTest.addResult("Main resource was shown.");
+        if (!WebInspector.panels.scripts.breakpointsActivated)
+            InspectorTest.addResult("Breakpoints are deactivated.");
+        else
+            InspectorTest.addResult("Error: breakpoints are activated.");
+        InspectorTest.ensureDebuggerDisabled(ensureDebuggerDisabledCallback);
+    }
+
+    function ensureDebuggerDisabledCallback()
+    {
+        InspectorTest.addResult("Debugger was disabled.");
+        InspectorTest.completeTest();
+    }
+};
 
 </script>
 </head>
 
-<body onload="onload()">
+<body onload="runTest()">
 <p>
 Tests that breakpoints are not activated on page reload.<a href="https://bugs.webkit.org/show_bug.cgi?id=41461">Bug 41461</a>
 </p>
-
 </body>
 </html>
-
-

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list