[Release] Webkit2-efl-123997_0.11.113
[framework/web/webkit-efl.git] / ManualTests / inspector-wrappers / inspector-wrappers-test-utils.js
1 var truealert = window.alert;  // we overwrite window.alert sometimes
2
3 // Walk up the caller chain and try to find a reference to the Inspector's window
4 function doAttack() {
5   var obj = doAttack.caller;
6   for (var i = 0; 
7        i < 1000 && (obj.arguments.length == 0 || !obj.arguments[0].target);
8        i++) {
9     obj = obj.caller;
10   }
11   if (i == 1000) return;
12   var win = obj.arguments[0].target.ownerDocument.defaultView;
13   xhr(win);
14 }
15
16 function xhr(win) {
17   var xhr = new win.XMLHttpRequest();
18   var url = prompt("Test failed. To prove it, I'm going " +
19                    "to make a cross-domain XMLHttpRequest. Where " +
20                    "would you like me to send it?\n\nHint: You can " +
21                    "also try a file:// URL.", "http://www.example.com/");
22   xhr.open("GET", url, false);
23   xhr.send();
24   truealert("Result:\n\n" + xhr.responseText);
25 }
26
27 function instructions(params) {
28   var str = "<p>This test tries to make a cross-domain XMLHttpRequest to " +
29     "check whether JavaScript object wrappers are working (bug 16837, bug 16011).</p>" +
30     "<p>View this page from an http:// URL to ensure that it's in a different " +
31     "origin from the Inspector.</p>" +
32     "<p>Instructions:</p>" +
33     "<ol>" + 
34     "<li>Right click the box" + 
35     "<img id=logo src='../resources/webkit-background.png'" + 
36       "style='border: 1px solid black; display: block; margin: 1em;'>" + 
37     "<li>Choose \"Inspect Element\" from the context menu";
38   if (params.console) {
39     str += "<li>Select the Console";
40     str += "<li>Type " + params.trigger + " into the console and hit Enter";
41   } else {
42     str += "<li>" + params.trigger;
43   }
44   str +=  "<li>If the test failed, a prompt will appear.</ol>";
45   document.write(str);
46 }