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

Unified Diff: chrome/test/data/extensions/platform_apps/web_view/shim/main.js

Issue 2700613003: Enable find-in-page across GuestViews. (Closed)
Patch Set: Created 3 years, 9 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: chrome/test/data/extensions/platform_apps/web_view/shim/main.js
diff --git a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js
index dfedddcd7315d03324beb360b30cdeeb9ec1b699..05f1875996f2f0785b9c025dcad8ad8b1b94ccc8 100644
--- a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js
+++ b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js
@@ -2556,19 +2556,22 @@ function testZoomAPI() {
document.body.appendChild(webview);
};
+var testFindPage =
+ 'data:text/html,Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
+ 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
+ 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
+ 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
+ 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
+ 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
+ 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
+ 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
+ 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
+ 'Dog dog dog Dog dog dogcatDog dogDogdog.<br><br>' +
+ '<a href="about:blank">Click here!</a>';
+
function testFindAPI() {
var webview = new WebView();
- webview.src = 'data:text/html,Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br><br>' +
- '<a href="about:blank">Click here!</a>';
+ webview.src = testFindPage;
var loadstopListener2 = function(e) {
embedder.test.assertEq(webview.src, "about:blank");
@@ -2642,17 +2645,8 @@ function testFindAPI() {
function testFindAPI_findupdate() {
var webview = new WebView();
- webview.src = 'data:text/html,Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br>' +
- 'Dog dog dog Dog dog dogcatDog dogDogdog.<br><br>' +
- '<a href="about:blank">Click here!</a>';
+ webview.src = testFindPage;
+
var canceledTest = false;
webview.addEventListener('loadstop', function(e) {
// Test the |findupdate| event.
@@ -2684,6 +2678,54 @@ function testFindAPI_findupdate() {
document.body.appendChild(webview);
};
+function testFindInMultipleWebViews() {
+ var webviews = [new WebView(), new WebView(), new WebView()];
+ var success = [];
+ for (var i in webviews) {
+ webviews[i].src = testFindPage;
+ success[i] = false;
+ }
+
+ var loadstopListener = function(id, e) {
+ LOG("Searching WebView " + id + ".");
+
+ // Test find results.
+ webviews[id].find("dog", {}, function(results) {
+ embedder.test.assertEq(results.numberOfMatches, 100);
+ embedder.test.assertTrue(results.selectionRect.width > 0);
+ embedder.test.assertTrue(results.selectionRect.height > 0);
+
+ // Test finding next active matches.
+ webviews[id].find("dog");
+ webviews[id].find("dog");
+ webviews[id].find("dog");
+ webviews[id].find("dog");
+ webviews[id].find("dog", {}, function(results) {
+ embedder.test.assertEq(results.activeMatchOrdinal, 6);
+
+ LOG("Searched WebView " + id + " successfully.");
+ success[id] = true;
+ for (var i in success) {
ncarter (slow) 2017/03/27 23:21:36 You can use Promise.all here to avoid the |success
paulmeyer 2017/03/31 18:31:16 Okay, I've replaced the test with your code mostly
+ if (!success[i]) {
+ return;
+ }
+ }
+
+ // The test only succeeds once all WebViews have been searched
+ // successfully.
+ embedder.test.succeed();
+ });
+ });
+ };
+
+ // Search in all WebViews simultaneously.
+ for (var i in webviews) {
+ webviews[i].addEventListener(
+ 'loadstop', loadstopListener.bind(undefined, i));
+ document.body.appendChild(webviews[i]);
+ }
+}
+
function testLoadDataAPI() {
var webview = new WebView();
webview.src = 'about:blank';
@@ -3142,6 +3184,7 @@ embedder.test.testList = {
'testZoomAPI' : testZoomAPI,
'testFindAPI': testFindAPI,
'testFindAPI_findupdate': testFindAPI,
+ 'testFindInMultipleWebViews': testFindInMultipleWebViews,
'testLoadDataAPI': testLoadDataAPI,
'testResizeEvents': testResizeEvents,
'testPerOriginZoomMode': testPerOriginZoomMode,

Powered by Google App Engine
This is Rietveld 408576698