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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/cache/resources/location-reload-window.html

Issue 2555963003: FasterLocationReload: use ReloadMainResource for JS exposed reloads (Closed)
Patch Set: test Created 4 years 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: third_party/WebKit/LayoutTests/http/tests/cache/resources/location-reload-window.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/cache/resources/location-reload-window.html b/third_party/WebKit/LayoutTests/http/tests/cache/resources/location-reload-window.html
new file mode 100644
index 0000000000000000000000000000000000000000..71b5970d6961f1fdc3d6e978c7cdb7af22da8a0c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/cache/resources/location-reload-window.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<body>
+<h1>random</h1>
+<script src="./random-cached.cgi"></script>
+<script>
+const lastRandomNumberKey = "lastRandomNumber";
+
+window.addEventListener("message", e => {
+ if (e.data != "START") {
+ window.opener.postMessage("FAIL: unknown; " + e.data, location.origin);
+ } else {
+ // window.top.randomNumber should be set by random-cached.cgi.
+ if (window.top === undefined || window.top.randomNumber === undefined) {
+ window.opener.postMessage("FAIL: randomNumber isn't defined",
+ location.origin);
+ return;
+ }
+
+ // If location.reload() is already triggered, lastRandomNumberKey should be
+ // stored in the sessionStorage. Otherwise, this is the first load.
+ const lastRandomNumberString = sessionStorage.getItem(lastRandomNumberKey);
+ if (lastRandomNumberString !== null) {
+ // sessionStorage returns DOMString and need to be converted to Number.
+ const lastRandomNumber = Number(lastRandomNumberString);
+
+ // Because the random-cached.cgi is a sub-resource, and set HTTP headers
+ // to allow caching, location.reload() should follow the cache-protocol to
+ // reuse the cached resource. That is to say the randomNumber should not
+ // be changed on the reload.
+ window.opener.postMessage(lastRandomNumber == top.randomNumber
+ ? "PASS"
+ : "FAIL: randomNumber was changed",
+ location.origin);
+ } else {
+ // Store the first randomNumber to the sessionStorage, and call reload().
+ // This window will send "READY" again, then receive "START".
+ sessionStorage.setItem(lastRandomNumberKey, top.randomNumber);
+ location.reload();
+ }
+ }
+}, false);
+
+// Send "READY" message first so that parent window can ensure to send messages.
+window.opener.postMessage("READY", location.origin);
+</script>
+</body>
+</html>
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/cache/location-reload.html ('k') | third_party/WebKit/Source/core/frame/History.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698