Commit fd875022 authored by Makoto Shimazu's avatar Makoto Shimazu Committed by Commit Bot

Add browser tests for bypassing service workers when shift-reload

Bug: 906542
Change-Id: I1b33376d5e07ed1725e3a5760d32a2837b4b83b4
Reviewed-on: https://chromium-review.googlesource.com/c/1345702Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Makoto Shimazu <shimazu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610783}
parent 60e8ad52
......@@ -9,7 +9,9 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/lock.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/shell/browser/shell.h"
......@@ -171,6 +173,48 @@ IN_PROC_BROWSER_TEST_F(ReloadCacheControlBrowserTest, NavigateToSame) {
CheckCacheControl(kExpectedCacheControlForReload);
}
// Reloading with ReloadType::NORMAL should respect service workers.
IN_PROC_BROWSER_TEST_F(ReloadCacheControlBrowserTest,
NormalReload_ControlledByServiceWorker) {
// Prepare for a service worker.
EXPECT_TRUE(NavigateToURL(shell(),
embedded_test_server()->GetURL(
"/service_worker/create_service_worker.html")));
EXPECT_EQ("DONE", EvalJs(shell(), "register('fetch_event_blob.js');"));
// Open a page served by the service worker.
EXPECT_TRUE(NavigateToURL(
shell(), embedded_test_server()->GetURL("/service_worker/empty.html")));
EXPECT_EQ(base::UTF8ToUTF16("Title"), shell()->web_contents()->GetTitle());
// Reload from the browser. The page is still controlled by the service
// worker.
ReloadBlockUntilNavigationsComplete(shell(), 1);
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
EXPECT_EQ(base::UTF8ToUTF16("Title"), shell()->web_contents()->GetTitle());
}
// Reloading with ReloadType::BYPASSING_CACHE should bypass service workers.
IN_PROC_BROWSER_TEST_F(ReloadCacheControlBrowserTest,
BypassingReload_ControlledByServiceWorker) {
// Prepare for a service worker.
EXPECT_TRUE(NavigateToURL(shell(),
embedded_test_server()->GetURL(
"/service_worker/create_service_worker.html")));
EXPECT_EQ("DONE", EvalJs(shell(), "register('fetch_event_blob.js');"));
// Open a page served by the service worker.
EXPECT_TRUE(NavigateToURL(
shell(), embedded_test_server()->GetURL("/service_worker/empty.html")));
EXPECT_EQ(base::UTF8ToUTF16("Title"), shell()->web_contents()->GetTitle());
// Reload from the browser with pressing shift key. It bypasses the service
// worker.
ReloadBypassingCacheBlockUntilNavigationsComplete(shell(), 1);
EXPECT_EQ(base::UTF8ToUTF16("ServiceWorker test - empty page"),
shell()->web_contents()->GetTitle());
}
} // namespace
} // namespace content
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment