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

Side by Side Diff: chrome/browser/extensions/service_worker_apitest.cc

Issue 1390943003: Bypass ServiceWorker when the request originates from isolated world. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/service_worker/content_script_fetch/background.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind_helpers.h" 5 #include "base/bind_helpers.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/test/base/ui_test_utils.h" 11 #include "chrome/test/base/ui_test_utils.h"
11 #include "components/version_info/version_info.h" 12 #include "components/version_info/version_info.h"
12 #include "content/public/browser/navigation_controller.h" 13 #include "content/public/browser/navigation_controller.h"
13 #include "content/public/browser/navigation_entry.h" 14 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
15 #include "content/public/common/content_switches.h" 16 #include "content/public/common/content_switches.h"
16 #include "content/public/common/page_type.h" 17 #include "content/public/common/page_type.h"
17 #include "content/public/test/background_sync_test_util.h" 18 #include "content/public/test/background_sync_test_util.h"
18 #include "content/public/test/browser_test_utils.h" 19 #include "content/public/test/browser_test_utils.h"
19 #include "extensions/browser/extension_host.h" 20 #include "extensions/browser/extension_host.h"
20 #include "extensions/browser/process_manager.h" 21 #include "extensions/browser/process_manager.h"
21 #include "extensions/test/background_page_watcher.h" 22 #include "extensions/test/background_page_watcher.h"
22 #include "extensions/test/extension_test_message_listener.h" 23 #include "extensions/test/extension_test_message_listener.h"
24 #include "net/test/embedded_test_server/embedded_test_server.h"
23 25
24 namespace extensions { 26 namespace extensions {
25 27
26 namespace { 28 namespace {
27 29
28 // Pass into ServiceWorkerTest::StartTestFromBackgroundPage to indicate that 30 // Pass into ServiceWorkerTest::StartTestFromBackgroundPage to indicate that
29 // registration is expected to succeed. 31 // registration is expected to succeed.
30 std::string* const kExpectSuccess = nullptr; 32 std::string* const kExpectSuccess = nullptr;
31 33
32 void DoNothingWithBool(bool b) {} 34 void DoNothingWithBool(bool b) {}
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 ASSERT_TRUE(content::ExecuteScriptAndExtractString( 386 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
385 web_contents, "window.runServiceWorker()", &result)); 387 web_contents, "window.runServiceWorker()", &result));
386 ASSERT_EQ("SERVICE_WORKER_READY", result); 388 ASSERT_EQ("SERVICE_WORKER_READY", result);
387 389
388 EXPECT_FALSE(sync_listener.was_satisfied()); 390 EXPECT_FALSE(sync_listener.was_satisfied());
389 // Resume firing by going online. 391 // Resume firing by going online.
390 content::background_sync_test_util::SetOnline(web_contents, true); 392 content::background_sync_test_util::SetOnline(web_contents, true);
391 EXPECT_TRUE(sync_listener.WaitUntilSatisfied()); 393 EXPECT_TRUE(sync_listener.WaitUntilSatisfied());
392 } 394 }
393 395
396 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest,
397 FetchFromContentScriptShouldNotGoToServiceWorkerOfPage) {
398 ASSERT_TRUE(StartEmbeddedTestServer());
399 GURL page_url = embedded_test_server()->GetURL(
400 "/extensions/api_test/service_worker/content_script_fetch/"
401 "controlled_page/index.html");
402 content::WebContents* tab =
403 browser()->tab_strip_model()->GetActiveWebContents();
404 ui_test_utils::NavigateToURL(browser(), page_url);
405 content::WaitForLoadStop(tab);
406
407 std::string value;
408 ASSERT_TRUE(
409 content::ExecuteScriptAndExtractString(tab, "register();", &value));
410 EXPECT_EQ("SW controlled", value);
411
412 ASSERT_TRUE(RunExtensionTest("service_worker/content_script_fetch"))
413 << message_;
414 }
415
394 } // namespace extensions 416 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/service_worker/content_script_fetch/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698