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

Unified Diff: extensions/browser/guest_view/web_view/web_view_apitest.cc

Issue 1582053002: Implement webview.captureVisibleRegion() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test so it waits for the first frame to be generated. Created 4 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/guest_view/web_view/web_view_apitest.cc
diff --git a/extensions/browser/guest_view/web_view/web_view_apitest.cc b/extensions/browser/guest_view/web_view/web_view_apitest.cc
index 9896e1389bd3b0a1aa1090937d27bb2f10be7550..beef19a81b772e7a5e6b7fae385ed3bccfd466a1 100644
--- a/extensions/browser/guest_view/web_view/web_view_apitest.cc
+++ b/extensions/browser/guest_view/web_view/web_view_apitest.cc
@@ -736,5 +736,34 @@ IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) {
LaunchApp("web_view/inside_iframe");
}
+IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestCaptureVisibleRegion) {
+ StartTestServer();
+
+ // Launch the app and wait until it's ready to load a test.
+ LaunchApp("web_view/apitest");
+
+ ExtensionTestMessageListener done_listener("TEST_PASSED", false);
+ done_listener.set_failure_message("TEST_FAILED");
+ // Run the test and wait until the guest WebContents is available and has
+ // finished loading.
+ ExtensionTestMessageListener guest_loaded_listener("guest-loaded", false);
+ EXPECT_TRUE(content::ExecuteScript(embedder_web_contents_,
+ "runTest('testCaptureVisibleRegion')"));
+
+ content::WebContents* guest_web_contents = GetGuestWebContents();
+ EXPECT_TRUE(guest_web_contents->GetRenderProcessHost()->IsForGuestsOnly());
+ ASSERT_TRUE(guest_loaded_listener.WaitUntilSatisfied());
+
+ // Wait for first frame to render before attempting pixel capture.
+ WaitForFirstFrame(guest_web_contents);
Fady Samuel 2016/01/25 16:20:39 This seems like a broken API if we have to do this
+
+ EXPECT_TRUE(content::ExecuteScript(embedder_web_contents_,
+ "captureVisibleRegionDoCapture()"));
+
+ // It would be nice not to replicate this.
+ ASSERT_TRUE(done_listener.WaitUntilSatisfied());
+
+ StopTestServer();
+}
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698