4 <script src=
"/js-test-resources/js-test.js"></script>
6 description("Testing navigator.sendBeacon() within same origin.");
8 window
.jsTestIsAsync
= true;
10 var binary_array
= new Uint32Array(10);
11 for (var i
= 0; i
< binary_array
.length
; i
++) {
12 binary_array
[i
] = 64 + i
;
15 var blob
= new Blob(["hello", " ", "world"], {type
: "text/plain;from-beacon=true"});
16 var form
= new FormData();
17 form
.append("key", "value");
27 payload
= tests
.shift();
32 debug("Sending beacon with type: " + Object
.prototype.toString
.call(payload
));
33 shouldBeTrue('navigator.sendBeacon("resources/save-beacon.php?name=same-origin", 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");
42 xhr
.onerror = function () {
43 testFailed("Unable to fetch beacon status");
50 if (window
.testRunner
) {
51 testRunner
.dumpAsText();
52 testRunner
.waitUntilDone();
53 testRunner
.dumpPingLoaderCallbacks();
59 <body onload=
"test();">