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

Unified Diff: LayoutTests/http/tests/navigation/resources/check-beacon.php

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/resources/check-beacon.php
diff --git a/LayoutTests/http/tests/navigation/resources/check-beacon.php b/LayoutTests/http/tests/navigation/resources/check-beacon.php
new file mode 100644
index 0000000000000000000000000000000000000000..0fadda190d02741e4c97da04fa8cb3caaf6ffa90
--- /dev/null
+++ b/LayoutTests/http/tests/navigation/resources/check-beacon.php
@@ -0,0 +1,26 @@
+<?php
+$beaconFilename = "beacon" . (isset($_REQUEST['name']) ? $_REQUEST['name'] : "") . ".txt";
+$retries = isset($_REQUEST['retries']) ? (int)$_REQUEST['retries'] : -1;
+while (!file_exists($beaconFilename) && $retries != 0) {
+ usleep(10000);
+ # file_exists() caches results, we want to invalidate the cache.
+ clearstatcache();
+ $retries--;
+}
+
+header('Content-Type: text/plain');
+header('Access-Control-Allow-Origin: *');
+if (file_exists($beaconFilename)) {
+ echo "Beacon sent successfully\n";
+ $beaconFile = fopen($beaconFilename, 'r');
+ while ($line = fgets($beaconFile)) {
+ $trimmed = trim($line);
+ if ($trimmed != "")
+ echo "$trimmed\n";
+ }
+ fclose($beaconFile);
+ unlink($beaconFilename);
+} else {
+ echo "Beacon not sent\n";
+}
+?>

Powered by Google App Engine
This is Rietveld 408576698