2010-08-17 Joseph Pecoraro <joepeck@webkit.org>
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Aug 2010 22:36:15 +0000 (22:36 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Aug 2010 22:36:15 +0000 (22:36 +0000)
        Reviewed by Pavel Feldman.

        Web Inspector: Add XMLHttpRequest Logging Tests
        https://bugs.webkit.org/show_bug.cgi?id=44092

        * http/tests/inspector/console-xhr-logging-expected.txt: Added.
        * http/tests/inspector/console-xhr-logging.html: Added.
        * http/tests/inspector/resources/xhr-exists.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/console-xhr-logging-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/inspector/console-xhr-logging.html [new file with mode: 0755]
LayoutTests/http/tests/inspector/resources/xhr-exists.html [new file with mode: 0644]

index f810607..7a60a82 100644 (file)
@@ -1,3 +1,14 @@
+2010-08-17  Joseph Pecoraro  <joepeck@webkit.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: Add XMLHttpRequest Logging Tests
+        https://bugs.webkit.org/show_bug.cgi?id=44092
+
+        * http/tests/inspector/console-xhr-logging-expected.txt: Added.
+        * http/tests/inspector/console-xhr-logging.html: Added.
+        * http/tests/inspector/resources/xhr-exists.html: Added.
+
 2010-08-17  Ojan Vafai  <ojan@chromium.org>
 
         Reviewed by Tony Chang.
diff --git a/LayoutTests/http/tests/inspector/console-xhr-logging-expected.txt b/LayoutTests/http/tests/inspector/console-xhr-logging-expected.txt
new file mode 100644 (file)
index 0000000..85cb331
--- /dev/null
@@ -0,0 +1,24 @@
+CONSOLE MESSAGE: line 11: enabled
+CONSOLE MESSAGE: line 40: sending a %s request to %s
+CONSOLE MESSAGE: line 40: sending a %s request to %s
+CONSOLE MESSAGE: line 40: sending a %s request to %s
+CONSOLE MESSAGE: line 21: disabled
+CONSOLE MESSAGE: line 40: sending a %s request to %s
+CONSOLE MESSAGE: line 40: sending a %s request to %s
+CONSOLE MESSAGE: line 40: sending a %s request to %s
+Tests that XMLHttpRequest Logging works when Enabled and doesn't show logs when Disabled.
+
+console-xhr-logging.html:11enabled
+console-xhr-logging.html:40sending a GET request to resources/xhr-exists.html
+XHR finished loading: "http://127.0.0.1:8000/inspector/resources/xhr-exists.html".
+console-xhr-logging.html:40sending a GET request to resources/xhr-does-not-exist.html
+resources/xhr-does-not-exist.htmlFailed to load resource: the server responded with a status of 404 (Not Found)
+XHR finished loading: "http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html".
+console-xhr-logging.html:40sending a POST request to resources/xhr-exists.html
+XHR finished loading: "http://127.0.0.1:8000/inspector/resources/xhr-exists.html".
+console-xhr-logging.html:21disabled
+console-xhr-logging.html:40sending a GET request to resources/xhr-exists.html
+console-xhr-logging.html:40sending a GET request to resources/xhr-does-not-exist.html
+resources/xhr-does-not-exist.htmlFailed to load resource: the server responded with a status of 404 (Not Found)
+console-xhr-logging.html:40sending a POST request to resources/xhr-exists.html
+
diff --git a/LayoutTests/http/tests/inspector/console-xhr-logging.html b/LayoutTests/http/tests/inspector/console-xhr-logging.html
new file mode 100755 (executable)
index 0000000..1c7582e
--- /dev/null
@@ -0,0 +1,79 @@
+<html>
+<head>
+<script src="inspector-test.js"></script>
+<script src="console-tests.js"></script>
+<script>
+
+function doit()
+{
+    // Enable XMLHttpRequest Logging.
+    evaluateInWebInspector("frontend_enableXMLHttpRequestLogging", function(result) {
+        console.log(result);
+        makeRequests();
+        testDisabled();
+    });
+}
+
+function testDisabled()
+{
+    // Disable XMLHttpRequest Logging.
+    evaluateInWebInspector("frontend_disableXMLHttpRequestLogging", function(result) {
+        console.log(result);
+        makeRequests();
+        dumpConsoleMessages();
+    });
+}
+
+function makeRequests()
+{
+    // 1. Page that exists.
+    requestHelper("GET", "resources/xhr-exists.html");
+    // 2. Page that doesn't exist.
+    requestHelper("GET", "resources/xhr-does-not-exist.html");
+    // 3. POST to a page.
+    requestHelper("POST", "resources/xhr-exists.html");
+}
+
+function requestHelper(method, url)
+{
+    // Make synchronous requests for simplicity.
+    console.log("sending a %s request to %s", method, url);
+    var xhr = new XMLHttpRequest();
+    xhr.open(method, url, false);
+    xhr.send();
+}
+
+function frontend_enableXMLHttpRequestLogging(testController)
+{
+    InspectorBackend.enableMonitoringXHR();
+    if (WebInspector.monitoringXHREnabled)
+        return "enabled";
+
+    testController.waitUntilDone();
+    frontend_addSniffer(WebInspector, "monitoringXHRWasEnabled", function() {
+         testController.notifyDone("enabled");
+    });
+}
+
+function frontend_disableXMLHttpRequestLogging(testController)
+{
+    InspectorBackend.disableMonitoringXHR();
+    if (!WebInspector.monitoringXHREnabled)
+        return "disabled";
+
+    testController.waitUntilDone();
+    frontend_addSniffer(WebInspector, "monitoringXHRWasDisabled", function() {
+        testController.notifyDone("disabled");
+    });
+}
+
+</script>
+</head>
+
+<body onload="onload()">
+<p>
+Tests that XMLHttpRequest Logging works when Enabled and doesn't show logs when Disabled.
+</p>
+
+</body>
+</html>
diff --git a/LayoutTests/http/tests/inspector/resources/xhr-exists.html b/LayoutTests/http/tests/inspector/resources/xhr-exists.html
new file mode 100644 (file)
index 0000000..8631aea
--- /dev/null
@@ -0,0 +1 @@
+<p>Existing File</p>