Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / extensions / browser / guest_view / web_view / web_view_apitest.cc
blob021a80ef28570a50db9e284d46941e0b01df3dda
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 "components/guest_view/browser/guest_view_manager.h"
12 #include "components/guest_view/browser/guest_view_manager_factory.h"
13 #include "components/guest_view/browser/test_guest_view_manager.h"
14 #include "content/public/browser/render_process_host.h"
15 #include "content/public/common/content_switches.h"
16 #include "content/public/test/browser_test_utils.h"
17 #include "content/public/test/test_renderer_host.h"
18 #include "content/public/test/test_utils.h"
19 #include "extensions/browser/api/test/test_api.h"
20 #include "extensions/browser/app_window/app_window.h"
21 #include "extensions/browser/app_window/app_window_registry.h"
22 #include "extensions/browser/extension_host.h"
23 #include "extensions/browser/guest_view/extensions_guest_view_manager_delegate.h"
24 #include "extensions/browser/process_manager.h"
25 #include "extensions/common/extension.h"
26 #include "extensions/common/extension_paths.h"
27 #include "extensions/shell/browser/shell_content_browser_client.h"
28 #include "extensions/shell/browser/shell_extension_system.h"
29 #include "extensions/shell/test/shell_test.h"
30 #include "extensions/test/extension_test_message_listener.h"
31 #include "net/base/filename_util.h"
32 #include "net/test/embedded_test_server/embedded_test_server.h"
33 #include "net/test/embedded_test_server/http_request.h"
34 #include "net/test/embedded_test_server/http_response.h"
35 #include "ui/gfx/switches.h"
37 using guest_view::GuestViewManager;
38 using guest_view::TestGuestViewManager;
40 namespace {
42 const char kEmptyResponsePath[] = "/close-socket";
43 const char kRedirectResponsePath[] = "/server-redirect";
44 const char kRedirectResponseFullPath[] = "/guest_redirect.html";
45 const char kUserAgentRedirectResponsePath[] = "/detect-user-agent";
46 const char kTestDataDirectory[] = "testDataDirectory";
47 const char kTestServerPort[] = "testServer.port";
48 const char kTestWebSocketPort[] = "testWebSocketPort";
50 class EmptyHttpResponse : public net::test_server::HttpResponse {
51 public:
52 std::string ToResponseString() const override { return std::string(); }
55 // Handles |request| by serving a redirect response if the |User-Agent| is
56 // foobar.
57 static scoped_ptr<net::test_server::HttpResponse> UserAgentResponseHandler(
58 const std::string& path,
59 const GURL& redirect_target,
60 const net::test_server::HttpRequest& request) {
61 if (!StartsWithASCII(path, request.relative_url, true))
62 return scoped_ptr<net::test_server::HttpResponse>();
64 std::map<std::string, std::string>::const_iterator it =
65 request.headers.find("User-Agent");
66 EXPECT_TRUE(it != request.headers.end());
67 if (!StartsWithASCII("foobar", it->second, true))
68 return scoped_ptr<net::test_server::HttpResponse>();
70 scoped_ptr<net::test_server::BasicHttpResponse> http_response(
71 new net::test_server::BasicHttpResponse);
72 http_response->set_code(net::HTTP_MOVED_PERMANENTLY);
73 http_response->AddCustomHeader("Location", redirect_target.spec());
74 return http_response.Pass();
77 class WebContentsHiddenObserver : public content::WebContentsObserver {
78 public:
79 WebContentsHiddenObserver(content::WebContents* web_contents,
80 const base::Closure& hidden_callback)
81 : WebContentsObserver(web_contents),
82 hidden_callback_(hidden_callback),
83 hidden_observed_(false) {
86 // WebContentsObserver.
87 void WasHidden() override {
88 hidden_observed_ = true;
89 hidden_callback_.Run();
92 bool hidden_observed() { return hidden_observed_; }
94 private:
95 base::Closure hidden_callback_;
96 bool hidden_observed_;
98 DISALLOW_COPY_AND_ASSIGN(WebContentsHiddenObserver);
101 // Handles |request| by serving a redirect response.
102 scoped_ptr<net::test_server::HttpResponse> RedirectResponseHandler(
103 const std::string& path,
104 const GURL& redirect_target,
105 const net::test_server::HttpRequest& request) {
106 if (!StartsWithASCII(path, request.relative_url, true))
107 return scoped_ptr<net::test_server::HttpResponse>();
109 scoped_ptr<net::test_server::BasicHttpResponse> http_response(
110 new net::test_server::BasicHttpResponse);
111 http_response->set_code(net::HTTP_MOVED_PERMANENTLY);
112 http_response->AddCustomHeader("Location", redirect_target.spec());
113 return http_response.Pass();
116 // Handles |request| by serving an empty response.
117 scoped_ptr<net::test_server::HttpResponse> EmptyResponseHandler(
118 const std::string& path,
119 const net::test_server::HttpRequest& request) {
120 if (StartsWithASCII(path, request.relative_url, true)) {
121 return scoped_ptr<net::test_server::HttpResponse>(new EmptyHttpResponse);
124 return scoped_ptr<net::test_server::HttpResponse>();
127 } // namespace
129 namespace extensions {
131 WebViewAPITest::WebViewAPITest() {
132 GuestViewManager::set_factory_for_testing(&factory_);
135 void WebViewAPITest::LaunchApp(const std::string& app_location) {
136 base::FilePath test_data_dir;
137 PathService::Get(DIR_TEST_DATA, &test_data_dir);
138 test_data_dir = test_data_dir.AppendASCII(app_location.c_str());
140 test_config_.SetString(kTestDataDirectory,
141 net::FilePathToFileURL(test_data_dir).spec());
143 embedded_test_server()->ServeFilesFromDirectory(test_data_dir);
145 const Extension* extension = extension_system_->LoadApp(test_data_dir);
146 ASSERT_TRUE(extension);
147 extension_system_->LaunchApp(extension->id());
149 ExtensionTestMessageListener launch_listener("LAUNCHED", false);
150 launch_listener.set_failure_message("FAILURE");
151 ASSERT_TRUE(launch_listener.WaitUntilSatisfied());
153 embedder_web_contents_ = GetFirstAppWindowWebContents();
156 content::WebContents* WebViewAPITest::GetFirstAppWindowWebContents() {
157 const AppWindowRegistry::AppWindowList& app_window_list =
158 AppWindowRegistry::Get(browser_context_)->app_windows();
159 DCHECK(app_window_list.size() == 1);
160 return (*app_window_list.begin())->web_contents();
163 void WebViewAPITest::RunTest(const std::string& test_name,
164 const std::string& app_location) {
165 LaunchApp(app_location);
167 ExtensionTestMessageListener done_listener("TEST_PASSED", false);
168 done_listener.set_failure_message("TEST_FAILED");
169 ASSERT_TRUE(content::ExecuteScript(
170 embedder_web_contents_,
171 base::StringPrintf("runTest('%s')", test_name.c_str())))
172 << "Unable to start test.";
173 ASSERT_TRUE(done_listener.WaitUntilSatisfied());
176 void WebViewAPITest::RunTestOnMainThreadLoop() {
177 AppShellTest::RunTestOnMainThreadLoop();
178 GetGuestViewManager()->WaitForAllGuestsDeleted();
181 void WebViewAPITest::SetUpCommandLine(base::CommandLine* command_line) {
182 AppShellTest::SetUpCommandLine(command_line);
183 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc");
186 void WebViewAPITest::SetUpOnMainThread() {
187 AppShellTest::SetUpOnMainThread();
189 TestGetConfigFunction::set_test_config_state(&test_config_);
190 base::FilePath test_data_dir;
191 test_config_.SetInteger(kTestWebSocketPort, 0);
194 void WebViewAPITest::StartTestServer() {
195 // For serving guest pages.
196 if (!embedded_test_server()->InitializeAndWaitUntilReady()) {
197 LOG(ERROR) << "Failed to start test server.";
198 return;
201 test_config_.SetInteger(kTestServerPort, embedded_test_server()->port());
203 embedded_test_server()->RegisterRequestHandler(
204 base::Bind(&RedirectResponseHandler,
205 kRedirectResponsePath,
206 embedded_test_server()->GetURL(kRedirectResponseFullPath)));
208 embedded_test_server()->RegisterRequestHandler(
209 base::Bind(&EmptyResponseHandler, kEmptyResponsePath));
211 embedded_test_server()->RegisterRequestHandler(
212 base::Bind(
213 &UserAgentResponseHandler,
214 kUserAgentRedirectResponsePath,
215 embedded_test_server()->GetURL(kRedirectResponseFullPath)));
218 void WebViewAPITest::StopTestServer() {
219 if (!embedded_test_server()->ShutdownAndWaitUntilComplete()) {
220 LOG(ERROR) << "Failed to shutdown test server.";
224 void WebViewAPITest::TearDownOnMainThread() {
225 TestGetConfigFunction::set_test_config_state(nullptr);
227 AppShellTest::TearDownOnMainThread();
230 void WebViewAPITest::SendMessageToEmbedder(const std::string& message) {
231 EXPECT_TRUE(
232 content::ExecuteScript(
233 GetEmbedderWebContents(),
234 base::StringPrintf("onAppCommand('%s');", message.c_str())));
237 content::WebContents* WebViewAPITest::GetEmbedderWebContents() {
238 if (!embedder_web_contents_)
239 embedder_web_contents_ = GetFirstAppWindowWebContents();
240 return embedder_web_contents_;
243 TestGuestViewManager* WebViewAPITest::GetGuestViewManager() {
244 content::BrowserContext* context =
245 ShellContentBrowserClient::Get()->GetBrowserContext();
246 TestGuestViewManager* manager = static_cast<TestGuestViewManager*>(
247 TestGuestViewManager::FromBrowserContext(context));
248 // TestGuestViewManager::WaitForSingleGuestCreated may and will get called
249 // before a guest is created.
250 if (!manager) {
251 manager = static_cast<TestGuestViewManager*>(
252 GuestViewManager::CreateWithDelegate(
253 context,
254 scoped_ptr<guest_view::GuestViewManagerDelegate>(
255 new ExtensionsGuestViewManagerDelegate(context))));
257 return manager;
260 void WebViewAPITest::SendMessageToGuestAndWait(
261 const std::string& message,
262 const std::string& wait_message) {
263 scoped_ptr<ExtensionTestMessageListener> listener;
264 if (!wait_message.empty())
265 listener.reset(new ExtensionTestMessageListener(wait_message, false));
267 EXPECT_TRUE(
268 content::ExecuteScript(
269 GetGuestWebContents(),
270 base::StringPrintf("onAppCommand('%s');", message.c_str())));
272 if (listener)
273 ASSERT_TRUE(listener->WaitUntilSatisfied());
276 void WebViewDPIAPITest::SetUp() {
277 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
278 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor,
279 base::StringPrintf("%f", scale()));
280 WebViewAPITest::SetUp();
283 content::WebContents* WebViewAPITest::GetGuestWebContents() {
284 return GetGuestViewManager()->WaitForSingleGuestCreated();
287 // Occasionally hits NOTIMPLEMENTED on Linux. https://crbug.com/422998
288 #if defined(OS_LINUX)
289 #define MAYBE_AcceptTouchEvents DISABLED_AcceptTouchEvents
290 #else
291 #define MAYBE_AcceptTouchEvents AcceptTouchEvents
292 #endif
293 IN_PROC_BROWSER_TEST_F(WebViewAPITest, MAYBE_AcceptTouchEvents) {
294 LaunchApp("web_view/accept_touch_events");
296 content::RenderViewHost* embedder_rvh =
297 GetEmbedderWebContents()->GetRenderViewHost();
299 bool embedder_has_touch_handler =
300 content::RenderViewHostTester::HasTouchEventHandler(embedder_rvh);
301 EXPECT_FALSE(embedder_has_touch_handler);
303 SendMessageToGuestAndWait("install-touch-handler", "installed-touch-handler");
305 // Note that we need to wait for the installed/registered touch handler to
306 // appear in browser process before querying |embedder_rvh|.
307 // In practice, since we do a roundrtip from browser process to guest and
308 // back, this is sufficient.
309 embedder_has_touch_handler =
310 content::RenderViewHostTester::HasTouchEventHandler(embedder_rvh);
311 EXPECT_TRUE(embedder_has_touch_handler);
313 SendMessageToGuestAndWait("uninstall-touch-handler",
314 "uninstalled-touch-handler");
315 // Same as the note above about waiting.
316 embedder_has_touch_handler =
317 content::RenderViewHostTester::HasTouchEventHandler(embedder_rvh);
318 EXPECT_FALSE(embedder_has_touch_handler);
321 // This test verifies that hiding the embedder also hides the guest.
322 IN_PROC_BROWSER_TEST_F(WebViewAPITest, EmbedderVisibilityChanged) {
323 LaunchApp("web_view/visibility_changed");
325 scoped_refptr<content::MessageLoopRunner> loop_runner(
326 new content::MessageLoopRunner);
327 WebContentsHiddenObserver observer(GetGuestWebContents(),
328 loop_runner->QuitClosure());
330 // Handled in web_view/visibility_changed/main.js
331 SendMessageToEmbedder("hide-embedder");
332 if (!observer.hidden_observed())
333 loop_runner->Run();
336 // Test for http://crbug.com/419611.
337 IN_PROC_BROWSER_TEST_F(WebViewAPITest, DisplayNoneSetSrc) {
338 LaunchApp("web_view/display_none_set_src");
339 // Navigate the guest while it's in "display: none" state.
340 SendMessageToEmbedder("navigate-guest");
341 GetGuestViewManager()->WaitForSingleGuestCreated();
343 // Now attempt to navigate the guest again.
344 SendMessageToEmbedder("navigate-guest");
346 ExtensionTestMessageListener test_passed_listener("WebViewTest.PASSED",
347 false);
348 // Making the guest visible would trigger loadstop.
349 SendMessageToEmbedder("show-guest");
350 EXPECT_TRUE(test_passed_listener.WaitUntilSatisfied());
353 // This test verifies that hiding the guest triggers WebContents::WasHidden().
354 IN_PROC_BROWSER_TEST_F(WebViewAPITest, GuestVisibilityChanged) {
355 LaunchApp("web_view/visibility_changed");
357 scoped_refptr<content::MessageLoopRunner> loop_runner(
358 new content::MessageLoopRunner);
359 WebContentsHiddenObserver observer(GetGuestWebContents(),
360 loop_runner->QuitClosure());
362 // Handled in web_view/visibility_changed/main.js
363 SendMessageToEmbedder("hide-guest");
364 if (!observer.hidden_observed())
365 loop_runner->Run();
368 // This test ensures that closing app window on 'loadcommit' does not crash.
369 // The test launches an app with guest and closes the window on loadcommit. It
370 // then launches the app window again. The process is repeated 3 times.
371 // http://crbug.com/291278
372 #if defined(OS_WIN)
373 #define MAYBE_CloseOnLoadcommit DISABLED_CloseOnLoadcommit
374 #else
375 #define MAYBE_CloseOnLoadcommit CloseOnLoadcommit
376 #endif
377 IN_PROC_BROWSER_TEST_F(WebViewAPITest, MAYBE_CloseOnLoadcommit) {
378 LaunchApp("web_view/close_on_loadcommit");
379 ExtensionTestMessageListener test_done_listener("done-close-on-loadcommit",
380 false);
381 ASSERT_TRUE(test_done_listener.WaitUntilSatisfied());
384 // This test verifies that reloading the embedder reloads the guest (and doest
385 // not crash).
386 IN_PROC_BROWSER_TEST_F(WebViewAPITest, ReloadEmbedder) {
387 // Just load a guest from other test, we do not want to add a separate
388 // app for this test.
389 LaunchApp("web_view/visibility_changed");
391 ExtensionTestMessageListener launched_again_listener("LAUNCHED", false);
392 embedder_web_contents_->GetController().Reload(false);
393 ASSERT_TRUE(launched_again_listener.WaitUntilSatisfied());
396 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAllowTransparencyAttribute) {
397 RunTest("testAllowTransparencyAttribute", "web_view/apitest");
400 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAPIMethodExistence) {
401 RunTest("testAPIMethodExistence", "web_view/apitest");
404 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAssignSrcAfterCrash) {
405 RunTest("testAssignSrcAfterCrash", "web_view/apitest");
408 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAutosizeAfterNavigation) {
409 RunTest("testAutosizeAfterNavigation", "web_view/apitest");
412 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAutosizeBeforeNavigation) {
413 RunTest("testAutosizeBeforeNavigation", "web_view/apitest");
416 IN_PROC_BROWSER_TEST_F(WebViewDPIAPITest, TestAutosizeBeforeNavigation) {
417 RunTest("testAutosizeBeforeNavigation", "web_view/apitest");
420 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAutosizeHeight) {
421 RunTest("testAutosizeHeight", "web_view/apitest");
424 IN_PROC_BROWSER_TEST_F(WebViewDPIAPITest, TestAutosizeHeight) {
425 RunTest("testAutosizeHeight", "web_view/apitest");
428 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAutosizeRemoveAttributes) {
429 RunTest("testAutosizeRemoveAttributes", "web_view/apitest");
432 IN_PROC_BROWSER_TEST_F(WebViewDPIAPITest, TestAutosizeRemoveAttributes) {
433 RunTest("testAutosizeRemoveAttributes", "web_view/apitest");
436 // http://crbug.com/473177
437 IN_PROC_BROWSER_TEST_F(WebViewAPITest,
438 DISABLED_TestAutosizeWithPartialAttributes) {
439 RunTest("testAutosizeWithPartialAttributes", "web_view/apitest");
442 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestCannotMutateEventName) {
443 RunTest("testCannotMutateEventName", "web_view/apitest");
446 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestChromeExtensionRelativePath) {
447 RunTest("testChromeExtensionRelativePath", "web_view/apitest");
450 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestChromeExtensionURL) {
451 RunTest("testChromeExtensionURL", "web_view/apitest");
454 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestContentLoadEvent) {
455 RunTest("testContentLoadEvent", "web_view/apitest");
458 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDeclarativeWebRequestAPI) {
459 StartTestServer();
460 RunTest("testDeclarativeWebRequestAPI", "web_view/apitest");
461 StopTestServer();
464 IN_PROC_BROWSER_TEST_F(WebViewAPITest,
465 TestDeclarativeWebRequestAPISendMessage) {
466 StartTestServer();
467 RunTest("testDeclarativeWebRequestAPISendMessage", "web_view/apitest");
468 StopTestServer();
471 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDestroyOnEventListener) {
472 RunTest("testDestroyOnEventListener", "web_view/apitest");
475 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogAlert) {
476 RunTest("testDialogAlert", "web_view/dialog");
479 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogConfirm) {
480 RunTest("testDialogConfirm", "web_view/dialog");
483 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogConfirmCancel) {
484 RunTest("testDialogConfirmCancel", "web_view/dialog");
487 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogConfirmDefaultCancel) {
488 RunTest("testDialogConfirmDefaultCancel", "web_view/dialog");
491 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogConfirmDefaultGCCancel) {
492 RunTest("testDialogConfirmDefaultGCCancel", "web_view/dialog");
495 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogPrompt) {
496 RunTest("testDialogPrompt", "web_view/dialog");
499 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDisplayNoneWebviewLoad) {
500 RunTest("testDisplayNoneWebviewLoad", "web_view/apitest");
503 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDisplayNoneWebviewRemoveChild) {
504 RunTest("testDisplayNoneWebviewRemoveChild", "web_view/apitest");
507 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestEventName) {
508 RunTest("testEventName", "web_view/apitest");
511 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestExecuteScript) {
512 RunTest("testExecuteScript", "web_view/apitest");
515 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestExecuteScriptFail) {
516 RunTest("testExecuteScriptFail", "web_view/apitest");
519 IN_PROC_BROWSER_TEST_F(WebViewAPITest,
520 TestExecuteScriptIsAbortedWhenWebViewSourceIsChanged) {
521 RunTest("testExecuteScriptIsAbortedWhenWebViewSourceIsChanged",
522 "web_view/apitest");
525 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestFindAPI) {
526 RunTest("testFindAPI", "web_view/apitest");
529 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestFindAPI_findupdate) {
530 RunTest("testFindAPI_findupdate", "web_view/apitest");
533 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestGetProcessId) {
534 RunTest("testGetProcessId", "web_view/apitest");
537 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestHiddenBeforeNavigation) {
538 RunTest("testHiddenBeforeNavigation", "web_view/apitest");
541 IN_PROC_BROWSER_TEST_F(WebViewAPITest,
542 TestInlineScriptFromAccessibleResources) {
543 RunTest("testInlineScriptFromAccessibleResources", "web_view/apitest");
546 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestInvalidChromeExtensionURL) {
547 RunTest("testInvalidChromeExtensionURL", "web_view/apitest");
550 IN_PROC_BROWSER_TEST_F(WebViewAPITest,
551 TestLoadAbortChromeExtensionURLWrongPartition) {
552 RunTest("testLoadAbortChromeExtensionURLWrongPartition", "web_view/apitest");
555 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortEmptyResponse) {
556 StartTestServer();
557 RunTest("testLoadAbortEmptyResponse", "web_view/apitest");
558 StopTestServer();
561 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortIllegalChromeURL) {
562 RunTest("testLoadAbortIllegalChromeURL", "web_view/apitest");
565 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortIllegalFileURL) {
566 RunTest("testLoadAbortIllegalFileURL", "web_view/apitest");
569 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortIllegalJavaScriptURL) {
570 RunTest("testLoadAbortIllegalJavaScriptURL", "web_view/apitest");
573 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortInvalidNavigation) {
574 RunTest("testLoadAbortInvalidNavigation", "web_view/apitest");
577 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortNonWebSafeScheme) {
578 RunTest("testLoadAbortNonWebSafeScheme", "web_view/apitest");
581 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadProgressEvent) {
582 RunTest("testLoadProgressEvent", "web_view/apitest");
585 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadStartLoadRedirect) {
586 StartTestServer();
587 RunTest("testLoadStartLoadRedirect", "web_view/apitest");
588 StopTestServer();
591 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNavigateAfterResize) {
592 RunTest("testNavigateAfterResize", "web_view/apitest");
595 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNavigationToExternalProtocol) {
596 RunTest("testNavigationToExternalProtocol", "web_view/apitest");
599 IN_PROC_BROWSER_TEST_F(WebViewAPITest,
600 TestNavOnConsecutiveSrcAttributeChanges) {
601 RunTest("testNavOnConsecutiveSrcAttributeChanges", "web_view/apitest");
604 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNavOnSrcAttributeChange) {
605 RunTest("testNavOnSrcAttributeChange", "web_view/apitest");
608 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNewWindow) {
609 StartTestServer();
610 RunTest("testNewWindow", "web_view/apitest");
611 StopTestServer();
614 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNewWindowNoPreventDefault) {
615 StartTestServer();
616 RunTest("testNewWindowNoPreventDefault", "web_view/apitest");
617 StopTestServer();
620 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNewWindowNoReferrerLink) {
621 StartTestServer();
622 RunTest("testNewWindowNoReferrerLink", "web_view/apitest");
623 StopTestServer();
626 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNewWindowTwoListeners) {
627 StartTestServer();
628 RunTest("testNewWindowTwoListeners", "web_view/apitest");
629 StopTestServer();
632 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestOnEventProperty) {
633 RunTest("testOnEventProperties", "web_view/apitest");
636 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestPartitionChangeAfterNavigation) {
637 RunTest("testPartitionChangeAfterNavigation", "web_view/apitest");
640 IN_PROC_BROWSER_TEST_F(WebViewAPITest,
641 TestPartitionRemovalAfterNavigationFails) {
642 RunTest("testPartitionRemovalAfterNavigationFails", "web_view/apitest");
645 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestReassignSrcAttribute) {
646 RunTest("testReassignSrcAttribute", "web_view/apitest");
649 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestRemoveWebviewOnExit) {
650 StartTestServer();
652 // Launch the app and wait until it's ready to load a test.
653 LaunchApp("web_view/apitest");
655 GURL::Replacements replace_host;
656 replace_host.SetHostStr("localhost");
658 // Run the test and wait until the guest WebContents is available and has
659 // finished loading.
660 ExtensionTestMessageListener guest_loaded_listener("guest-loaded", false);
661 EXPECT_TRUE(content::ExecuteScript(embedder_web_contents_,
662 "runTest('testRemoveWebviewOnExit')"));
664 content::WebContents* guest_web_contents = GetGuestWebContents();
665 EXPECT_TRUE(guest_web_contents->GetRenderProcessHost()->IsIsolatedGuest());
666 ASSERT_TRUE(guest_loaded_listener.WaitUntilSatisfied());
668 content::WebContentsDestroyedWatcher destroyed_watcher(guest_web_contents);
670 // Tell the embedder to kill the guest.
671 EXPECT_TRUE(content::ExecuteScript(embedder_web_contents_,
672 "removeWebviewOnExitDoCrash()"));
674 // Wait until the guest WebContents is destroyed.
675 destroyed_watcher.Wait();
676 StopTestServer();
679 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestReload) {
680 RunTest("testReload", "web_view/apitest");
683 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestReloadAfterTerminate) {
684 RunTest("testReloadAfterTerminate", "web_view/apitest");
687 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestRemoveSrcAttribute) {
688 RunTest("testRemoveSrcAttribute", "web_view/apitest");
691 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestRemoveWebviewAfterNavigation) {
692 RunTest("testRemoveWebviewAfterNavigation", "web_view/apitest");
695 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestResizeWebviewResizesContent) {
696 RunTest("testResizeWebviewResizesContent", "web_view/apitest");
699 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestTerminateAfterExit) {
700 RunTest("testTerminateAfterExit", "web_view/apitest");
703 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPI) {
704 StartTestServer();
705 RunTest("testWebRequestAPI", "web_view/apitest");
706 StopTestServer();
709 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPIWithHeaders) {
710 StartTestServer();
711 RunTest("testWebRequestAPIWithHeaders", "web_view/apitest");
712 StopTestServer();
715 // Tests the existence of WebRequest API event objects on the request
716 // object, on the webview element, and hanging directly off webview.
717 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPIExistence) {
718 RunTest("testWebRequestAPIExistence", "web_view/apitest");
721 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPIGoogleProperty) {
722 RunTest("testWebRequestAPIGoogleProperty", "web_view/apitest");
725 // This test verifies that webview.contentWindow works inside an iframe
726 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) {
727 LaunchApp("web_view/inside_iframe");
731 } // namespace extensions