OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <html> |
| 3 <head> |
| 4 <script src="/js-test-resources/js-test.js"></script> |
| 5 <script> |
| 6 description("Testing navigator.sendBeacon() within same origin."); |
| 7 |
| 8 window.jsTestIsAsync = true; |
| 9 |
| 10 var binary_array = new Uint32Array(10); |
| 11 for (var i = 0; i < binary_array.length; i++) { |
| 12 binary_array[i] = 64 + i; |
| 13 } |
| 14 |
| 15 var blob = new Blob(["hello", " ", "world"]); |
| 16 var form = new FormData(); |
| 17 form.append("key", "value"); |
| 18 |
| 19 var tests = [ |
| 20 "SameOrigin", |
| 21 binary_array, |
| 22 blob, |
| 23 form]; |
| 24 |
| 25 var payload; |
| 26 function testOne() { |
| 27 payload = tests.shift(); |
| 28 if (!payload) { |
| 29 finishJSTest(); |
| 30 return; |
| 31 } |
| 32 debug("Sending beacon with type: " + Object.prototype.toString.call(payload)
); |
| 33 shouldBeTrue('navigator.sendBeacon("resources/save-beacon.php?name=same-orig
in", payload);'); |
| 34 var xhr = new XMLHttpRequest(); |
| 35 xhr.open("GET", "resources/check-beacon.php?name=same-origin"); |
| 36 xhr.onload = function () { |
| 37 var lines = xhr.responseText.split("\n"); |
| 38 for (var i in lines) |
| 39 testPassed(lines[i]); |
| 40 testOne(); |
| 41 }; |
| 42 xhr.onerror = function () { |
| 43 testFailed("Unable to fetch beacon status"); |
| 44 testOne(); |
| 45 }; |
| 46 xhr.send(); |
| 47 } |
| 48 |
| 49 function test() { |
| 50 if (window.testRunner) { |
| 51 testRunner.dumpAsText(); |
| 52 testRunner.waitUntilDone(); |
| 53 testRunner.dumpPingLoaderCallbacks(); |
| 54 } |
| 55 testOne(); |
| 56 } |
| 57 </script> |
| 58 </head> |
| 59 <body onload="test();"> |
| 60 </body> |
| 61 </html> |
OLD | NEW |