Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Unified Diff: LayoutTests/http/tests/navigation/beacon-same-origin.html

Issue 232053005: Implement navigator.sendBeacon() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Revert CSP checking on redirects Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/navigation/beacon-same-origin.html
diff --git a/LayoutTests/http/tests/navigation/beacon-same-origin.html b/LayoutTests/http/tests/navigation/beacon-same-origin.html
new file mode 100644
index 0000000000000000000000000000000000000000..9f3e1d8bc15ff3563867352e8692623a1a780a17
--- /dev/null
+++ b/LayoutTests/http/tests/navigation/beacon-same-origin.html
@@ -0,0 +1,61 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src="/js-test-resources/js-test.js"></script>
+<script>
+description("Testing navigator.sendBeacon() within same origin.");
+
+window.jsTestIsAsync = true;
+
+var binary_array = new Uint32Array(10);
+for (var i = 0; i < binary_array.length; i++) {
+ binary_array[i] = 64 + i;
+}
+
+var blob = new Blob(["hello", " ", "world"]);
+var form = new FormData();
+form.append("key", "value");
+
+var tests = [
+ "SameOrigin",
+ binary_array,
+ blob,
+ form];
+
+var payload;
+function testOne() {
+ payload = tests.shift();
+ if (!payload) {
+ finishJSTest();
+ return;
+ }
+ debug("Sending beacon with type: " + Object.prototype.toString.call(payload));
+ shouldBeTrue('navigator.sendBeacon("resources/save-beacon.php?name=same-origin", payload);');
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "resources/check-beacon.php?name=same-origin");
+ xhr.onload = function () {
+ var lines = xhr.responseText.split("\n");
+ for (var i in lines)
+ testPassed(lines[i]);
+ testOne();
+ };
+ xhr.onerror = function () {
+ testFailed("Unable to fetch beacon status");
+ testOne();
+ };
+ xhr.send();
+}
+
+function test() {
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ testRunner.dumpPingLoaderCallbacks();
+ }
+ testOne();
+}
+</script>
+</head>
+<body onload="test();">
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698