Add tests for <area ping>
[WebKit-https.git] / LayoutTests / http / tests / navigation / ping-attribute / resources / utilities.js
1 function setCookie()
2 {
3     try {
4         var xhr = new XMLHttpRequest;
5         xhr.open("GET", "../../cookies/resources/setCookies.cgi", false);
6         xhr.setRequestHeader("SET-COOKIE", "hello=world;path=/");
7         xhr.send(null);
8         if (xhr.status != 200) {
9             document.getElementsByTagName("body")[0].appendChild(document.createTextNode("FAILED: cookie not set"));
10             if (window.testRunner)
11                 testRunner.notifyDone();
12         }
13     } catch (e) {
14         document.getElementsByTagName("body")[0].appendChild(document.createTextNode("FAILED: cookie not set"));
15         if (window.testRunner)
16             testRunner.notifyDone();
17     }
18 }
19
20 function clearLastPingResultAndRunTest(callback)
21 {
22     function done()
23     {
24         if (window.testRunner)
25             testRunner.notifyDone();
26     }
27
28     var xhr = new XMLHttpRequest;
29     xhr.open("GET", "resources/delete-ping.php", true /* async */);
30     xhr.send(null);
31     xhr.onload = callback;
32     xhr.onerror = done;
33 }
34
35 function clickElement(element)
36 {
37     if (!window.eventSender)
38         return;
39     eventSender.mouseMoveTo(element.offsetLeft + 2, element.offsetTop + 2);
40     eventSender.mouseDown();
41     eventSender.mouseUp();
42 }