Add tests for <area ping>
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Apr 2016 18:03:38 +0000 (18:03 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Apr 2016 18:03:38 +0000 (18:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79438
<rdar://problem/22586699>

Reviewed by Alexey Proskuryakov.

* http/tests/navigation/ping-attribute/anchor-cookie.html: Extracted out code into functions setCookie(),
clearLastPingResultAndRunTest() and clickElement() (defined in utilities.js) so that they can be
used by this test and others. Also added HTML5 doctype declaration since it is unnecessary to run
this test in quirks mode.
* http/tests/navigation/ping-attribute/area-cookie-expected.txt: Added.
* http/tests/navigation/ping-attribute/area-cookie.html: Added.
* http/tests/navigation/ping-attribute/area-cross-origin-expected.txt: Added.
* http/tests/navigation/ping-attribute/area-cross-origin-from-https-expected.txt: Added.
* http/tests/navigation/ping-attribute/area-cross-origin-from-https.html: Added.
* http/tests/navigation/ping-attribute/area-cross-origin.html: Added.
* http/tests/navigation/ping-attribute/area-same-origin-expected.txt: Added.
* http/tests/navigation/ping-attribute/area-same-origin.html: Added.
* http/tests/navigation/ping-attribute/resources/utilities.js: Added.
(setCookie):
(clearLastPingResultAndRunTest.done):
(clearLastPingResultAndRunTest):
(clickElement):

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

LayoutTests/ChangeLog
LayoutTests/http/tests/navigation/ping-attribute/anchor-cookie.html
LayoutTests/http/tests/navigation/ping-attribute/area-cookie-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/ping-attribute/area-cookie.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/ping-attribute/area-cross-origin-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/ping-attribute/area-cross-origin-from-https-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/ping-attribute/area-cross-origin-from-https.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/ping-attribute/area-cross-origin.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/ping-attribute/area-same-origin-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/ping-attribute/area-same-origin.html [new file with mode: 0644]
LayoutTests/http/tests/navigation/ping-attribute/resources/utilities.js [new file with mode: 0644]

index 0e9da2b..f6bec9e 100644 (file)
@@ -1,3 +1,29 @@
+2016-04-21  Daniel Bates  <dabates@apple.com>
+
+        Add tests for <area ping>
+        https://bugs.webkit.org/show_bug.cgi?id=79438
+        <rdar://problem/22586699>
+
+        Reviewed by Alexey Proskuryakov.
+
+        * http/tests/navigation/ping-attribute/anchor-cookie.html: Extracted out code into functions setCookie(),
+        clearLastPingResultAndRunTest() and clickElement() (defined in utilities.js) so that they can be
+        used by this test and others. Also added HTML5 doctype declaration since it is unnecessary to run
+        this test in quirks mode.
+        * http/tests/navigation/ping-attribute/area-cookie-expected.txt: Added.
+        * http/tests/navigation/ping-attribute/area-cookie.html: Added.
+        * http/tests/navigation/ping-attribute/area-cross-origin-expected.txt: Added.
+        * http/tests/navigation/ping-attribute/area-cross-origin-from-https-expected.txt: Added.
+        * http/tests/navigation/ping-attribute/area-cross-origin-from-https.html: Added.
+        * http/tests/navigation/ping-attribute/area-cross-origin.html: Added.
+        * http/tests/navigation/ping-attribute/area-same-origin-expected.txt: Added.
+        * http/tests/navigation/ping-attribute/area-same-origin.html: Added.
+        * http/tests/navigation/ping-attribute/resources/utilities.js: Added.
+        (setCookie):
+        (clearLastPingResultAndRunTest.done):
+        (clearLastPingResultAndRunTest):
+        (clickElement):
+
 2016-04-21  Antoine Quint  <graouts@apple.com>
 
         Creating a large number of WebGL contexts should recycle older contexts
index e5360a9..1773500 100644 (file)
@@ -1,46 +1,27 @@
+<!DOCTYPE html>
 <html><head>
 <title>Ping</title>
+<script src="resources/utilities.js"></script>
 <script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.overridePreference("WebKitHyperlinkAuditingEnabled", 1);
+    testRunner.waitUntilDone();
+}
 
-var testCalled = false;
-
-function test() {
-    if (!testCalled) {
-        if (window.testRunner) {
-            testRunner.dumpAsText();
-            testRunner.overridePreference("WebKitHyperlinkAuditingEnabled", 1);
-            testRunner.waitUntilDone();
-        }
-        testCalled = true;
-        return;
-    }
-    try {
-        var xhr = new XMLHttpRequest();
-        xhr.open("GET", "../../cookies/resources/setCookies.cgi", false);
-        xhr.setRequestHeader("SET-COOKIE", "hello=world;path=/");
-        xhr.send(null);
-        if (xhr.status != 200) {
-            document.getElementsByTagName("body")[0].appendChild(document.createTextNode("FAILED: cookie not set"));
-            if (window.testRunner)
-                testRunner.notifyDone();
-        }
-    } catch (e) {
-        document.getElementsByTagName("body")[0].appendChild(document.createTextNode("FAILED: cookie not set"));
-        if (window.testRunner)
-            testRunner.notifyDone();
-    }
-
-    if (window.eventSender) {
-        var a = document.getElementById("a");
-        eventSender.mouseMoveTo(a.offsetLeft + 2, a.offsetTop + 2);
-        eventSender.mouseDown();
-        eventSender.mouseUp();
-    }
+function test()
+{
+    setCookie();
+    clickElement(document.getElementById("a"));
 }
 
+window.onload = function ()
+{
+    clearLastPingResultAndRunTest(test);
+}
 </script>
 </head>
-<body onload="test();">
-<img src="../resources/delete-ping.php" onload="test();" onerror="test();"></img>
+<body>
+<img src="non-existent-image.jpg">
 <a id="a" href="../resources/check-ping.php" ping="../resources/save-Ping.php">Navigate and send ping</a>
 </body></html>
diff --git a/LayoutTests/http/tests/navigation/ping-attribute/area-cookie-expected.txt b/LayoutTests/http/tests/navigation/ping-attribute/area-cookie-expected.txt
new file mode 100644 (file)
index 0000000..305b7cc
--- /dev/null
@@ -0,0 +1,6 @@
+Ping sent successfully
+CONTENT_TYPE: text/ping
+HTTP_COOKIE: hello=world
+HTTP_PING_FROM: http://127.0.0.1:8000/navigation/ping-attribute/area-cookie.html
+HTTP_PING_TO: http://127.0.0.1:8000/navigation/resources/check-ping.php
+REQUEST_METHOD: POST
diff --git a/LayoutTests/http/tests/navigation/ping-attribute/area-cookie.html b/LayoutTests/http/tests/navigation/ping-attribute/area-cookie.html
new file mode 100644 (file)
index 0000000..6c2c6a5
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/utilities.js"></script>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.overridePreference("WebKitHyperlinkAuditingEnabled", 1);
+    testRunner.waitUntilDone();
+}
+
+function test()
+{
+    setCookie();
+    clickElement(document.querySelector("img"));
+}
+
+window.onload = function ()
+{
+    clearLastPingResultAndRunTest(test);
+}
+</script>
+</head>
+<body>
+    <img src="non-existent-image.jpg" width="128" height="128" usemap="#imagemap">
+    <map name="imagemap">
+        <area shape="rect" coords="0,0,128,128" href="../resources/check-ping.php" ping="../resources/save-Ping.php">
+    </map>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/navigation/ping-attribute/area-cross-origin-expected.txt b/LayoutTests/http/tests/navigation/ping-attribute/area-cross-origin-expected.txt
new file mode 100644 (file)
index 0000000..2e6a244
--- /dev/null
@@ -0,0 +1,6 @@
+Ping sent successfully
+CONTENT_TYPE: text/ping
+HTTP_PING_FROM: http://127.0.0.1:8000/navigation/ping-attribute/area-cross-origin.html
+HTTP_PING_TO: http://127.0.0.1:8000/navigation/resources/check-ping.php
+HTTP_REFERER: http://127.0.0.1:8000/navigation/ping-attribute/area-cross-origin.html
+REQUEST_METHOD: POST
diff --git a/LayoutTests/http/tests/navigation/ping-attribute/area-cross-origin-from-https-expected.txt b/LayoutTests/http/tests/navigation/ping-attribute/area-cross-origin-from-https-expected.txt
new file mode 100644 (file)
index 0000000..5b9614c
--- /dev/null
@@ -0,0 +1,4 @@
+Ping sent successfully
+CONTENT_TYPE: text/ping
+HTTP_PING_TO: https://127.0.0.1:8443/navigation/resources/check-ping.php
+REQUEST_METHOD: POST
diff --git a/LayoutTests/http/tests/navigation/ping-attribute/area-cross-origin-from-https.html b/LayoutTests/http/tests/navigation/ping-attribute/area-cross-origin-from-https.html
new file mode 100644 (file)
index 0000000..ef2ce4c
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/utilities.js"></script>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.overridePreference("WebKitHyperlinkAuditingEnabled", 1);
+    testRunner.waitUntilDone();
+}
+
+if (location.protocol != "https:")
+    location = "https://127.0.0.1:8443/navigation/ping-attribute/area-cross-origin-from-https.html"
+
+function test()
+{
+    clickElement(document.querySelector("img"));
+}
+
+window.onload = function ()
+{
+    clearLastPingResultAndRunTest(test);
+}
+</script>
+</head>
+<body>
+    <img src="non-existent-image.jpg" width="128" height="128" usemap="#imagemap">
+    <map name="imagemap">
+        <area shape="rect" coords="0,0,128,128" href="../resources/check-ping.php" ping="http://localhost:8000/navigation/resources/save-Ping.php?test=/navigation/ping-attribute/area-cross-origin-from-https.html">
+    </map>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/navigation/ping-attribute/area-cross-origin.html b/LayoutTests/http/tests/navigation/ping-attribute/area-cross-origin.html
new file mode 100644 (file)
index 0000000..2e1c01c
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/utilities.js"></script>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.overridePreference("WebKitHyperlinkAuditingEnabled", 1);
+    testRunner.waitUntilDone();
+}
+
+function test()
+{
+    clickElement(document.querySelector("img"));
+}
+
+window.onload = function ()
+{
+    clearLastPingResultAndRunTest(test);
+}
+</script>
+</head>
+<body>
+    <img src="non-existent-image.jpg" width="128" height="128" usemap="#imagemap">
+    <map name="imagemap">
+        <area shape="rect" coords="0,0,128,128" href="../resources/check-ping.php" ping="http://localhost:8000/navigation/resources/save-Ping.php">
+    </map>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/navigation/ping-attribute/area-same-origin-expected.txt b/LayoutTests/http/tests/navigation/ping-attribute/area-same-origin-expected.txt
new file mode 100644 (file)
index 0000000..fc17660
--- /dev/null
@@ -0,0 +1,5 @@
+Ping sent successfully
+CONTENT_TYPE: text/ping
+HTTP_PING_FROM: http://127.0.0.1:8000/navigation/ping-attribute/area-same-origin.html
+HTTP_PING_TO: http://127.0.0.1:8000/navigation/resources/check-ping.php
+REQUEST_METHOD: POST
diff --git a/LayoutTests/http/tests/navigation/ping-attribute/area-same-origin.html b/LayoutTests/http/tests/navigation/ping-attribute/area-same-origin.html
new file mode 100644 (file)
index 0000000..f9c2436
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/utilities.js"></script>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.overridePreference("WebKitHyperlinkAuditingEnabled", 1);
+    testRunner.waitUntilDone();
+}
+
+function test()
+{
+    clickElement(document.querySelector("img"));
+}
+
+window.onload = function ()
+{
+    clearLastPingResultAndRunTest(test);
+}
+</script>
+</head>
+<body>
+    <img src="non-existent-image.jpg" width="128" height="128" usemap="#imagemap">
+    <map name="imagemap">
+        <area shape="rect" coords="0,0,128,128" href="../resources/check-ping.php" ping="../resources/save-Ping.php">
+    </map>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/navigation/ping-attribute/resources/utilities.js b/LayoutTests/http/tests/navigation/ping-attribute/resources/utilities.js
new file mode 100644 (file)
index 0000000..056674e
--- /dev/null
@@ -0,0 +1,42 @@
+function setCookie()
+{
+    try {
+        var xhr = new XMLHttpRequest;
+        xhr.open("GET", "../../cookies/resources/setCookies.cgi", false);
+        xhr.setRequestHeader("SET-COOKIE", "hello=world;path=/");
+        xhr.send(null);
+        if (xhr.status != 200) {
+            document.getElementsByTagName("body")[0].appendChild(document.createTextNode("FAILED: cookie not set"));
+            if (window.testRunner)
+                testRunner.notifyDone();
+        }
+    } catch (e) {
+        document.getElementsByTagName("body")[0].appendChild(document.createTextNode("FAILED: cookie not set"));
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }
+}
+
+function clearLastPingResultAndRunTest(callback)
+{
+    function done()
+    {
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }
+
+    var xhr = new XMLHttpRequest;
+    xhr.open("GET", "resources/delete-ping.php", true /* async */);
+    xhr.send(null);
+    xhr.onload = callback;
+    xhr.onerror = done;
+}
+
+function clickElement(element)
+{
+    if (!window.eventSender)
+        return;
+    eventSender.mouseMoveTo(element.offsetLeft + 2, element.offsetTop + 2);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}