OLD | NEW |
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 "chrome/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 6 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
7 #include "content/public/test/browser_test_utils.h" | 7 #include "content/public/test/browser_test_utils.h" |
8 #include "extensions/test/extension_test_message_listener.h" | 8 #include "extensions/test/extension_test_message_listener.h" |
9 | 9 |
10 namespace extensions { | 10 namespace extensions { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // Page must reload in order for the service worker to take control. | 57 // Page must reload in order for the service worker to take control. |
58 contents->GetController().Reload(true); | 58 contents->GetController().Reload(true); |
59 content::WaitForLoadStop(contents); | 59 content::WaitForLoadStop(contents); |
60 | 60 |
61 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 61 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
62 contents, "window.domAutomationController.send(document.body.innerText);", | 62 contents, "window.domAutomationController.send(document.body.innerText);", |
63 &output)); | 63 &output)); |
64 EXPECT_EQ("Caught a fetch!", output); | 64 EXPECT_EQ("Caught a fetch!", output); |
65 } | 65 } |
66 | 66 |
| 67 // Binding that was created on the v8::Context of the worker for testing |
| 68 // purposes should bind an empty object to chrome. |
| 69 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, ServiceWorkerChromeBinding) { |
| 70 ASSERT_TRUE(RunExtensionTest("service_worker/bindings")) << message_; |
| 71 content::WebContents* contents = |
| 72 browser()->tab_strip_model()->GetActiveWebContents(); |
| 73 content::WaitForLoadStop(contents); |
| 74 |
| 75 std::string output; |
| 76 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 77 contents, "window.domAutomationController.send(document.body.innerText);", |
| 78 &output)); |
| 79 EXPECT_EQ("No Fetch Event yet.", output); |
| 80 |
| 81 // Page must reload in order for the service worker to take control. |
| 82 contents->GetController().Reload(true); |
| 83 content::WaitForLoadStop(contents); |
| 84 |
| 85 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 86 contents, "window.domAutomationController.send(document.body.innerText);", |
| 87 &output)); |
| 88 EXPECT_EQ("object", output); |
| 89 } |
| 90 |
67 } // namespace extensions | 91 } // namespace extensions |
OLD | NEW |