Remove unused parameter.
[chromium-blink-merge.git] / extensions / browser / guest_view / web_view / web_view_apitest.cc
blob61b87bde5ae18bed96907e4a5979c93c2c25c8c7
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "extensions/browser/guest_view/web_view/web_view_apitest.h"
7 #include "base/command_line.h"
8 #include "base/path_service.h"
9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h"
11 #include "content/public/browser/render_process_host.h"
12 #include "content/public/common/content_switches.h"
13 #include "content/public/test/browser_test_utils.h"
14 #include "content/public/test/test_renderer_host.h"
15 #include "content/public/test/test_utils.h"
16 #include "extensions/browser/api/test/test_api.h"
17 #include "extensions/browser/app_window/app_window.h"
18 #include "extensions/browser/app_window/app_window_registry.h"
19 #include "extensions/browser/extension_host.h"
20 #include "extensions/browser/guest_view/guest_view_manager.h"
21 #include "extensions/browser/guest_view/guest_view_manager_factory.h"
22 #include "extensions/browser/guest_view/test_guest_view_manager.h"
23 #include "extensions/browser/process_manager.h"
24 #include "extensions/common/extension.h"
25 #include "extensions/common/extension_paths.h"
26 #include "extensions/shell/browser/shell_content_browser_client.h"
27 #include "extensions/shell/browser/shell_extension_system.h"
28 #include "extensions/shell/test/shell_test.h"
29 #include "extensions/test/extension_test_message_listener.h"
30 #include "net/base/filename_util.h"
31 #include "net/test/embedded_test_server/embedded_test_server.h"
32 #include "net/test/embedded_test_server/http_request.h"
33 #include "net/test/embedded_test_server/http_response.h"
34 #include "ui/gfx/switches.h"
36 namespace {
38 const char kEmptyResponsePath[] = "/close-socket";
39 const char kRedirectResponsePath[] = "/server-redirect";
40 const char kRedirectResponseFullPath[] = "/guest_redirect.html";
41 const char kUserAgentRedirectResponsePath[] = "/detect-user-agent";
42 const char kTestDataDirectory[] = "testDataDirectory";
43 const char kTestServerPort[] = "testServer.port";
44 const char kTestWebSocketPort[] = "testWebSocketPort";
46 class EmptyHttpResponse : public net::test_server::HttpResponse {
47 public:
48 std::string ToResponseString() const override { return std::string(); }
51 // Handles |request| by serving a redirect response if the |User-Agent| is
52 // foobar.
53 static scoped_ptr<net::test_server::HttpResponse> UserAgentResponseHandler(
54 const std::string& path,
55 const GURL& redirect_target,
56 const net::test_server::HttpRequest& request) {
57 if (!StartsWithASCII(path, request.relative_url, true))
58 return scoped_ptr<net::test_server::HttpResponse>();
60 std::map<std::string, std::string>::const_iterator it =
61 request.headers.find("User-Agent");
62 EXPECT_TRUE(it != request.headers.end());
63 if (!StartsWithASCII("foobar", it->second, true))
64 return scoped_ptr<net::test_server::HttpResponse>();
66 scoped_ptr<net::test_server::BasicHttpResponse> http_response(
67 new net::test_server::BasicHttpResponse);
68 http_response->set_code(net::HTTP_MOVED_PERMANENTLY);
69 http_response->AddCustomHeader("Location", redirect_target.spec());
70 return http_response.Pass();
73 class WebContentsHiddenObserver : public content::WebContentsObserver {
74 public:
75 WebContentsHiddenObserver(content::WebContents* web_contents,
76 const base::Closure& hidden_callback)
77 : WebContentsObserver(web_contents),
78 hidden_callback_(hidden_callback),
79 hidden_observed_(false) {
82 // WebContentsObserver.
83 void WasHidden() override {
84 hidden_observed_ = true;
85 hidden_callback_.Run();
88 bool hidden_observed() { return hidden_observed_; }
90 private:
91 base::Closure hidden_callback_;
92 bool hidden_observed_;
94 DISALLOW_COPY_AND_ASSIGN(WebContentsHiddenObserver);
97 // Handles |request| by serving a redirect response.
98 scoped_ptr<net::test_server::HttpResponse> RedirectResponseHandler(
99 const std::string& path,
100 const GURL& redirect_target,
101 const net::test_server::HttpRequest& request) {
102 if (!StartsWithASCII(path, request.relative_url, true))
103 return scoped_ptr<net::test_server::HttpResponse>();
105 scoped_ptr<net::test_server::BasicHttpResponse> http_response(
106 new net::test_server::BasicHttpResponse);
107 http_response->set_code(net::HTTP_MOVED_PERMANENTLY);
108 http_response->AddCustomHeader("Location", redirect_target.spec());
109 return http_response.Pass();
112 // Handles |request| by serving an empty response.
113 scoped_ptr<net::test_server::HttpResponse> EmptyResponseHandler(
114 const std::string& path,
115 const net::test_server::HttpRequest& request) {
116 if (StartsWithASCII(path, request.relative_url, true)) {
117 return scoped_ptr<net::test_server::HttpResponse>(new EmptyHttpResponse);
120 return scoped_ptr<net::test_server::HttpResponse>();
123 } // namespace
125 namespace extensions {
127 WebViewAPITest::WebViewAPITest() {
128 GuestViewManager::set_factory_for_testing(&factory_);
131 void WebViewAPITest::LaunchApp(const std::string& app_location) {
132 base::FilePath test_data_dir;
133 PathService::Get(DIR_TEST_DATA, &test_data_dir);
134 test_data_dir = test_data_dir.AppendASCII(app_location.c_str());
136 test_config_.SetString(kTestDataDirectory,
137 net::FilePathToFileURL(test_data_dir).spec());
139 embedded_test_server()->ServeFilesFromDirectory(test_data_dir);
141 const Extension* extension = extension_system_->LoadApp(test_data_dir);
142 ASSERT_TRUE(extension);
143 extension_system_->LaunchApp(extension->id());
145 ExtensionTestMessageListener launch_listener("LAUNCHED", false);
146 launch_listener.set_failure_message("FAILURE");
147 ASSERT_TRUE(launch_listener.WaitUntilSatisfied());
149 embedder_web_contents_ = GetFirstAppWindowWebContents();
152 content::WebContents* WebViewAPITest::GetFirstAppWindowWebContents() {
153 const AppWindowRegistry::AppWindowList& app_window_list =
154 AppWindowRegistry::Get(browser_context_)->app_windows();
155 DCHECK(app_window_list.size() == 1);
156 return (*app_window_list.begin())->web_contents();
159 void WebViewAPITest::RunTest(const std::string& test_name,
160 const std::string& app_location) {
161 LaunchApp(app_location);
163 ExtensionTestMessageListener done_listener("TEST_PASSED", false);
164 done_listener.set_failure_message("TEST_FAILED");
165 ASSERT_TRUE(content::ExecuteScript(
166 embedder_web_contents_,
167 base::StringPrintf("runTest('%s')", test_name.c_str())))
168 << "Unable to start test.";
169 ASSERT_TRUE(done_listener.WaitUntilSatisfied());
172 void WebViewAPITest::RunTestOnMainThreadLoop() {
173 AppShellTest::RunTestOnMainThreadLoop();
174 GetGuestViewManager()->WaitForAllGuestsDeleted();
177 void WebViewAPITest::SetUpCommandLine(base::CommandLine* command_line) {
178 AppShellTest::SetUpCommandLine(command_line);
179 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc");
182 void WebViewAPITest::SetUpOnMainThread() {
183 AppShellTest::SetUpOnMainThread();
185 TestGetConfigFunction::set_test_config_state(&test_config_);
186 base::FilePath test_data_dir;
187 test_config_.SetInteger(kTestWebSocketPort, 0);
190 void WebViewAPITest::StartTestServer() {
191 // For serving guest pages.
192 if (!embedded_test_server()->InitializeAndWaitUntilReady()) {
193 LOG(ERROR) << "Failed to start test server.";
194 return;
197 test_config_.SetInteger(kTestServerPort, embedded_test_server()->port());
199 embedded_test_server()->RegisterRequestHandler(
200 base::Bind(&RedirectResponseHandler,
201 kRedirectResponsePath,
202 embedded_test_server()->GetURL(kRedirectResponseFullPath)));
204 embedded_test_server()->RegisterRequestHandler(
205 base::Bind(&EmptyResponseHandler, kEmptyResponsePath));
207 embedded_test_server()->RegisterRequestHandler(
208 base::Bind(
209 &UserAgentResponseHandler,
210 kUserAgentRedirectResponsePath,
211 embedded_test_server()->GetURL(kRedirectResponseFullPath)));
214 void WebViewAPITest::StopTestServer() {
215 if (!embedded_test_server()->ShutdownAndWaitUntilComplete()) {
216 LOG(ERROR) << "Failed to shutdown test server.";
220 void WebViewAPITest::TearDownOnMainThread() {
221 TestGetConfigFunction::set_test_config_state(nullptr);
223 AppShellTest::TearDownOnMainThread();
226 void WebViewAPITest::SendMessageToEmbedder(const std::string& message) {
227 EXPECT_TRUE(
228 content::ExecuteScript(
229 GetEmbedderWebContents(),
230 base::StringPrintf("onAppCommand('%s');", message.c_str())));
233 content::WebContents* WebViewAPITest::GetEmbedderWebContents() {
234 if (!embedder_web_contents_)
235 embedder_web_contents_ = GetFirstAppWindowWebContents();
236 return embedder_web_contents_;
239 TestGuestViewManager* WebViewAPITest::GetGuestViewManager() {
240 return static_cast<TestGuestViewManager*>(
241 TestGuestViewManager::FromBrowserContext(
242 ShellContentBrowserClient::Get()->GetBrowserContext()));
245 void WebViewAPITest::SendMessageToGuestAndWait(
246 const std::string& message,
247 const std::string& wait_message) {
248 scoped_ptr<ExtensionTestMessageListener> listener;
249 if (!wait_message.empty())
250 listener.reset(new ExtensionTestMessageListener(wait_message, false));
252 EXPECT_TRUE(
253 content::ExecuteScript(
254 GetGuestWebContents(),
255 base::StringPrintf("onAppCommand('%s');", message.c_str())));
257 if (listener)
258 ASSERT_TRUE(listener->WaitUntilSatisfied());
261 void WebViewDPIAPITest::SetUp() {
262 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
263 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor,
264 base::StringPrintf("%f", scale()));
265 WebViewAPITest::SetUp();
268 content::WebContents* WebViewAPITest::GetGuestWebContents() {
269 return GetGuestViewManager()->WaitForSingleGuestCreated();
272 // Occasionally hits NOTIMPLEMENTED on Linux. https://crbug.com/422998
273 #if defined(OS_LINUX)
274 #define MAYBE_AcceptTouchEvents DISABLED_AcceptTouchEvents
275 #else
276 #define MAYBE_AcceptTouchEvents AcceptTouchEvents
277 #endif
278 IN_PROC_BROWSER_TEST_F(WebViewAPITest, MAYBE_AcceptTouchEvents) {
279 LaunchApp("web_view/accept_touch_events");
281 content::RenderViewHost* embedder_rvh =
282 GetEmbedderWebContents()->GetRenderViewHost();
284 bool embedder_has_touch_handler =
285 content::RenderViewHostTester::HasTouchEventHandler(embedder_rvh);
286 EXPECT_FALSE(embedder_has_touch_handler);
288 SendMessageToGuestAndWait("install-touch-handler", "installed-touch-handler");
290 // Note that we need to wait for the installed/registered touch handler to
291 // appear in browser process before querying |embedder_rvh|.
292 // In practice, since we do a roundrtip from browser process to guest and
293 // back, this is sufficient.
294 embedder_has_touch_handler =
295 content::RenderViewHostTester::HasTouchEventHandler(embedder_rvh);
296 EXPECT_TRUE(embedder_has_touch_handler);
298 SendMessageToGuestAndWait("uninstall-touch-handler",
299 "uninstalled-touch-handler");
300 // Same as the note above about waiting.
301 embedder_has_touch_handler =
302 content::RenderViewHostTester::HasTouchEventHandler(embedder_rvh);
303 EXPECT_FALSE(embedder_has_touch_handler);
306 // This test verifies that hiding the embedder also hides the guest.
307 IN_PROC_BROWSER_TEST_F(WebViewAPITest, EmbedderVisibilityChanged) {
308 LaunchApp("web_view/visibility_changed");
310 scoped_refptr<content::MessageLoopRunner> loop_runner(
311 new content::MessageLoopRunner);
312 WebContentsHiddenObserver observer(GetGuestWebContents(),
313 loop_runner->QuitClosure());
315 // Handled in web_view/visibility_changed/main.js
316 SendMessageToEmbedder("hide-embedder");
317 if (!observer.hidden_observed())
318 loop_runner->Run();
321 // Test for http://crbug.com/419611.
322 IN_PROC_BROWSER_TEST_F(WebViewAPITest, DisplayNoneSetSrc) {
323 LaunchApp("web_view/display_none_set_src");
324 // Navigate the guest while it's in "display: none" state.
325 SendMessageToEmbedder("navigate-guest");
326 GetGuestViewManager()->WaitForSingleGuestCreated();
328 // Now attempt to navigate the guest again.
329 SendMessageToEmbedder("navigate-guest");
331 ExtensionTestMessageListener test_passed_listener("WebViewTest.PASSED",
332 false);
333 // Making the guest visible would trigger loadstop.
334 SendMessageToEmbedder("show-guest");
335 EXPECT_TRUE(test_passed_listener.WaitUntilSatisfied());
338 // This test verifies that hiding the guest triggers WebContents::WasHidden().
339 IN_PROC_BROWSER_TEST_F(WebViewAPITest, GuestVisibilityChanged) {
340 LaunchApp("web_view/visibility_changed");
342 scoped_refptr<content::MessageLoopRunner> loop_runner(
343 new content::MessageLoopRunner);
344 WebContentsHiddenObserver observer(GetGuestWebContents(),
345 loop_runner->QuitClosure());
347 // Handled in web_view/visibility_changed/main.js
348 SendMessageToEmbedder("hide-guest");
349 if (!observer.hidden_observed())
350 loop_runner->Run();
353 // This test ensures that closing app window on 'loadcommit' does not crash.
354 // The test launches an app with guest and closes the window on loadcommit. It
355 // then launches the app window again. The process is repeated 3 times.
356 // http://crbug.com/291278
357 #if defined(OS_WIN)
358 #define MAYBE_CloseOnLoadcommit DISABLED_CloseOnLoadcommit
359 #else
360 #define MAYBE_CloseOnLoadcommit CloseOnLoadcommit
361 #endif
362 IN_PROC_BROWSER_TEST_F(WebViewAPITest, MAYBE_CloseOnLoadcommit) {
363 LaunchApp("web_view/close_on_loadcommit");
364 ExtensionTestMessageListener test_done_listener("done-close-on-loadcommit",
365 false);
366 ASSERT_TRUE(test_done_listener.WaitUntilSatisfied());
369 // This test verifies that reloading the embedder reloads the guest (and doest
370 // not crash).
371 IN_PROC_BROWSER_TEST_F(WebViewAPITest, ReloadEmbedder) {
372 // Just load a guest from other test, we do not want to add a separate
373 // app for this test.
374 LaunchApp("web_view/visibility_changed");
376 ExtensionTestMessageListener launched_again_listener("LAUNCHED", false);
377 embedder_web_contents_->GetController().Reload(false);
378 ASSERT_TRUE(launched_again_listener.WaitUntilSatisfied());
381 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAllowTransparencyAttribute) {
382 RunTest("testAllowTransparencyAttribute", "web_view/apitest");
385 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAPIMethodExistence) {
386 RunTest("testAPIMethodExistence", "web_view/apitest");
389 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAssignSrcAfterCrash) {
390 RunTest("testAssignSrcAfterCrash", "web_view/apitest");
393 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAutosizeAfterNavigation) {
394 RunTest("testAutosizeAfterNavigation", "web_view/apitest");
397 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAutosizeBeforeNavigation) {
398 RunTest("testAutosizeBeforeNavigation", "web_view/apitest");
401 IN_PROC_BROWSER_TEST_F(WebViewDPIAPITest, TestAutosizeBeforeNavigation) {
402 RunTest("testAutosizeBeforeNavigation", "web_view/apitest");
405 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAutosizeHeight) {
406 RunTest("testAutosizeHeight", "web_view/apitest");
409 IN_PROC_BROWSER_TEST_F(WebViewDPIAPITest, TestAutosizeHeight) {
410 RunTest("testAutosizeHeight", "web_view/apitest");
413 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAutosizeRemoveAttributes) {
414 RunTest("testAutosizeRemoveAttributes", "web_view/apitest");
417 IN_PROC_BROWSER_TEST_F(WebViewDPIAPITest, TestAutosizeRemoveAttributes) {
418 RunTest("testAutosizeRemoveAttributes", "web_view/apitest");
421 // http://crbug.com/473177
422 IN_PROC_BROWSER_TEST_F(WebViewAPITest,
423 DISABLED_TestAutosizeWithPartialAttributes) {
424 RunTest("testAutosizeWithPartialAttributes", "web_view/apitest");
427 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestCannotMutateEventName) {
428 RunTest("testCannotMutateEventName", "web_view/apitest");
431 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestChromeExtensionRelativePath) {
432 RunTest("testChromeExtensionRelativePath", "web_view/apitest");
435 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestChromeExtensionURL) {
436 RunTest("testChromeExtensionURL", "web_view/apitest");
439 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestContentLoadEvent) {
440 RunTest("testContentLoadEvent", "web_view/apitest");
443 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDeclarativeWebRequestAPI) {
444 StartTestServer();
445 RunTest("testDeclarativeWebRequestAPI", "web_view/apitest");
446 StopTestServer();
449 IN_PROC_BROWSER_TEST_F(WebViewAPITest,
450 TestDeclarativeWebRequestAPISendMessage) {
451 StartTestServer();
452 RunTest("testDeclarativeWebRequestAPISendMessage", "web_view/apitest");
453 StopTestServer();
456 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDestroyOnEventListener) {
457 RunTest("testDestroyOnEventListener", "web_view/apitest");
460 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogAlert) {
461 RunTest("testDialogAlert", "web_view/dialog");
464 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogConfirm) {
465 RunTest("testDialogConfirm", "web_view/dialog");
468 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogConfirmCancel) {
469 RunTest("testDialogConfirmCancel", "web_view/dialog");
472 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogConfirmDefaultCancel) {
473 RunTest("testDialogConfirmDefaultCancel", "web_view/dialog");
476 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogConfirmDefaultGCCancel) {
477 RunTest("testDialogConfirmDefaultGCCancel", "web_view/dialog");
480 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogPrompt) {
481 RunTest("testDialogPrompt", "web_view/dialog");
484 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDisplayNoneWebviewLoad) {
485 RunTest("testDisplayNoneWebviewLoad", "web_view/apitest");
488 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDisplayNoneWebviewRemoveChild) {
489 RunTest("testDisplayNoneWebviewRemoveChild", "web_view/apitest");
492 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestEventName) {
493 RunTest("testEventName", "web_view/apitest");
496 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestExecuteScript) {
497 RunTest("testExecuteScript", "web_view/apitest");
500 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestExecuteScriptFail) {
501 RunTest("testExecuteScriptFail", "web_view/apitest");
504 IN_PROC_BROWSER_TEST_F(WebViewAPITest,
505 TestExecuteScriptIsAbortedWhenWebViewSourceIsChanged) {
506 RunTest("testExecuteScriptIsAbortedWhenWebViewSourceIsChanged",
507 "web_view/apitest");
510 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestFindAPI) {
511 RunTest("testFindAPI", "web_view/apitest");
514 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestFindAPI_findupdate) {
515 RunTest("testFindAPI_findupdate", "web_view/apitest");
518 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestGetProcessId) {
519 RunTest("testGetProcessId", "web_view/apitest");
522 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestHiddenBeforeNavigation) {
523 RunTest("testHiddenBeforeNavigation", "web_view/apitest");
526 IN_PROC_BROWSER_TEST_F(WebViewAPITest,
527 TestInlineScriptFromAccessibleResources) {
528 RunTest("testInlineScriptFromAccessibleResources", "web_view/apitest");
531 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestInvalidChromeExtensionURL) {
532 RunTest("testInvalidChromeExtensionURL", "web_view/apitest");
535 IN_PROC_BROWSER_TEST_F(WebViewAPITest,
536 TestLoadAbortChromeExtensionURLWrongPartition) {
537 RunTest("testLoadAbortChromeExtensionURLWrongPartition", "web_view/apitest");
540 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortEmptyResponse) {
541 StartTestServer();
542 RunTest("testLoadAbortEmptyResponse", "web_view/apitest");
543 StopTestServer();
546 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortIllegalChromeURL) {
547 RunTest("testLoadAbortIllegalChromeURL", "web_view/apitest");
550 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortIllegalFileURL) {
551 RunTest("testLoadAbortIllegalFileURL", "web_view/apitest");
554 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortIllegalJavaScriptURL) {
555 RunTest("testLoadAbortIllegalJavaScriptURL", "web_view/apitest");
558 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortInvalidNavigation) {
559 RunTest("testLoadAbortInvalidNavigation", "web_view/apitest");
562 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortNonWebSafeScheme) {
563 RunTest("testLoadAbortNonWebSafeScheme", "web_view/apitest");
566 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadProgressEvent) {
567 RunTest("testLoadProgressEvent", "web_view/apitest");
570 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadStartLoadRedirect) {
571 StartTestServer();
572 RunTest("testLoadStartLoadRedirect", "web_view/apitest");
573 StopTestServer();
576 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNavigateAfterResize) {
577 RunTest("testNavigateAfterResize", "web_view/apitest");
580 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNavigationToExternalProtocol) {
581 RunTest("testNavigationToExternalProtocol", "web_view/apitest");
584 IN_PROC_BROWSER_TEST_F(WebViewAPITest,
585 TestNavOnConsecutiveSrcAttributeChanges) {
586 RunTest("testNavOnConsecutiveSrcAttributeChanges", "web_view/apitest");
589 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNavOnSrcAttributeChange) {
590 RunTest("testNavOnSrcAttributeChange", "web_view/apitest");
593 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNewWindow) {
594 StartTestServer();
595 RunTest("testNewWindow", "web_view/apitest");
596 StopTestServer();
599 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNewWindowNoPreventDefault) {
600 StartTestServer();
601 RunTest("testNewWindowNoPreventDefault", "web_view/apitest");
602 StopTestServer();
605 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNewWindowNoReferrerLink) {
606 StartTestServer();
607 RunTest("testNewWindowNoReferrerLink", "web_view/apitest");
608 StopTestServer();
611 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNewWindowTwoListeners) {
612 StartTestServer();
613 RunTest("testNewWindowTwoListeners", "web_view/apitest");
614 StopTestServer();
617 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestOnEventProperty) {
618 RunTest("testOnEventProperties", "web_view/apitest");
621 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestPartitionChangeAfterNavigation) {
622 RunTest("testPartitionChangeAfterNavigation", "web_view/apitest");
625 IN_PROC_BROWSER_TEST_F(WebViewAPITest,
626 TestPartitionRemovalAfterNavigationFails) {
627 RunTest("testPartitionRemovalAfterNavigationFails", "web_view/apitest");
630 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestReassignSrcAttribute) {
631 RunTest("testReassignSrcAttribute", "web_view/apitest");
634 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestRemoveWebviewOnExit) {
635 StartTestServer();
637 // Launch the app and wait until it's ready to load a test.
638 LaunchApp("web_view/apitest");
640 GURL::Replacements replace_host;
641 replace_host.SetHostStr("localhost");
643 // Run the test and wait until the guest WebContents is available and has
644 // finished loading.
645 ExtensionTestMessageListener guest_loaded_listener("guest-loaded", false);
646 EXPECT_TRUE(content::ExecuteScript(embedder_web_contents_,
647 "runTest('testRemoveWebviewOnExit')"));
649 content::WebContents* guest_web_contents = GetGuestWebContents();
650 EXPECT_TRUE(guest_web_contents->GetRenderProcessHost()->IsIsolatedGuest());
651 ASSERT_TRUE(guest_loaded_listener.WaitUntilSatisfied());
653 content::WebContentsDestroyedWatcher destroyed_watcher(guest_web_contents);
655 // Tell the embedder to kill the guest.
656 EXPECT_TRUE(content::ExecuteScript(embedder_web_contents_,
657 "removeWebviewOnExitDoCrash()"));
659 // Wait until the guest WebContents is destroyed.
660 destroyed_watcher.Wait();
661 StopTestServer();
664 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestReload) {
665 RunTest("testReload", "web_view/apitest");
668 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestReloadAfterTerminate) {
669 RunTest("testReloadAfterTerminate", "web_view/apitest");
672 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestRemoveSrcAttribute) {
673 RunTest("testRemoveSrcAttribute", "web_view/apitest");
676 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestRemoveWebviewAfterNavigation) {
677 RunTest("testRemoveWebviewAfterNavigation", "web_view/apitest");
680 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestResizeWebviewResizesContent) {
681 RunTest("testResizeWebviewResizesContent", "web_view/apitest");
684 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestTerminateAfterExit) {
685 RunTest("testTerminateAfterExit", "web_view/apitest");
688 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPI) {
689 StartTestServer();
690 RunTest("testWebRequestAPI", "web_view/apitest");
691 StopTestServer();
694 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPIWithHeaders) {
695 StartTestServer();
696 RunTest("testWebRequestAPIWithHeaders", "web_view/apitest");
697 StopTestServer();
700 // Tests the existence of WebRequest API event objects on the request
701 // object, on the webview element, and hanging directly off webview.
702 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPIExistence) {
703 RunTest("testWebRequestAPIExistence", "web_view/apitest");
706 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPIGoogleProperty) {
707 RunTest("testWebRequestAPIGoogleProperty", "web_view/apitest");
710 // This test verifies that webview.contentWindow works inside an iframe
711 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) {
712 LaunchApp("web_view/inside_iframe");
716 } // namespace extensions