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

Unified Diff: chrome/test/data/extensions/platform_apps/web_view/focus_visibility/window.js

Issue 2474323002: Implement WebContentsViewChildFrame::TakeFocus. (Closed)
Patch Set: remove logging and move pant kickcing out of loop Created 3 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
« no previous file with comments | « chrome/test/data/extensions/platform_apps/web_view/focus_visibility/window.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/platform_apps/web_view/focus_visibility/window.js
diff --git a/chrome/test/data/extensions/platform_apps/web_view/focus_visibility/window.js b/chrome/test/data/extensions/platform_apps/web_view/focus_visibility/window.js
index 3fbeb490e99b1966c4b21e5ea00acd155ca91816..3a7313445396259e1aed4556de0b0a5e9ae031be 100644
--- a/chrome/test/data/extensions/platform_apps/web_view/focus_visibility/window.js
+++ b/chrome/test/data/extensions/platform_apps/web_view/focus_visibility/window.js
@@ -1,6 +1,59 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+//
+'use strict';
+
+var webViewButtonFocused = false;
+var afterButtonFocused = false;
+
+var verifyBlocked = false;
+
+var isOopif = false;
+
+function handleWebviewFocusEvent(e) {
+ if (e.data === 'focus-event') {
+ e.stopImmediatePropagation();
+ webViewButtonFocused = true;
+ if (verifyBlocked) {
+ verifyBlocked = false;
+ chrome.test.sendMessage('WebViewInteractiveTest.WebViewButtonWasFocused');
+ }
+ }
+};
+
+function listenForWebViewFocus() {
+ window.addEventListener('message', handleWebviewFocusEvent);
+}
+
+function handleAfterFocusEvent(e) {
+ afterButtonFocused = true;
+ if (verifyBlocked) {
+ verifyBlocked = false;
+ chrome.test.sendMessage(
+ 'WebViewInteractiveTest.WebViewButtonWasNotFocused');
+ }
+};
+
+function listenForAfterFocus() {
+ document.querySelector('#after').addEventListener('focus',
+ handleAfterFocusEvent);
+}
+
+function listforForKeyup() {
+ console.log('set up keyup listeners');
+ window.addEventListener('keyup', function() {
+ if (isOopif || document.activeElement !== getWebView()) {
+ chrome.test.sendMessage('WebViewInteractiveTest.KeyUp');
+ }
+ });
+ window.addEventListener('message', function(e) {
+ if (e.data === 'guest-keyup') {
+ e.stopImmediatePropagation();
+ chrome.test.sendMessage('WebViewInteractiveTest.KeyUp');
+ }
+ });
+}
function setUpWebView(embedder) {
var webview = document.createElement('webview');
@@ -9,7 +62,15 @@ function setUpWebView(embedder) {
var url = 'http://localhost:' + config.testServer.port
+ '/extensions/platform_apps/web_view/focus_visibility/guest.html';
webview.onloadstop = function() {
- chrome.test.sendMessage('WebViewInteractiveTest.WebViewInitialized');
+ function callback(e) {
+ if (e.data === 'connected') {
+ e.stopImmediatePropagation();
+ window.removeEventListener('message', callback);
+ chrome.test.sendMessage('WebViewInteractiveTest.WebViewInitialized');
+ }
+ };
+ window.addEventListener('message', callback);
+ getWebView().contentWindow.postMessage('connect', '*');
};
webview.src = url;
console.log('Setting URL to "' + url + '".');
@@ -18,8 +79,7 @@ function setUpWebView(embedder) {
function reset() {
getWebView().style.visibility = 'visible';
- document.querySelector('button').focus();
- webViewButtonReceivedFocus = false;
+ document.querySelector('#before').focus();
}
function sendMessageToWebViewAndReceiveReply(message, replyCallback) {
@@ -39,21 +99,35 @@ function getWebView() {
window.onAppMessage = function(command) {
switch (command) {
+ case 'setOopif':
+ isOopif = true;
+ break;
case 'init':
+ listenForWebViewFocus();
+ listenForAfterFocus();
+ listforForKeyup();
+ document.querySelector('#before').focus();
setUpWebView(document.querySelector('div'));
break;
case 'reset':
reset();
- sendMessageToWebViewAndReceiveReply("reset", function() {
- chrome.test.sendMessage('WebViewInteractiveTest.DidReset');
+ sendMessageToWebViewAndReceiveReply("reset", function(reply) {
+ if (reply === 'reset-complete') {
+ webViewButtonFocused = false;
+ afterButtonFocused = false;
+ verifyBlocked = false;
+ chrome.test.sendMessage('WebViewInteractiveTest.DidReset');
+ }
});
break;
case 'verify':
- sendMessageToWebViewAndReceiveReply('verify', function(result) {
- chrome.test.sendMessage(result === 'was-focused' ?
- 'WebViewInteractiveTest.WebViewButtonWasFocused' :
- 'WebViewInteractiveTest.WebViewButtonWasNotFocused');
- });
+ if (!webViewButtonFocused && !afterButtonFocused) {
+ verifyBlocked = true;
+ return;
+ }
+ chrome.test.sendMessage(webViewButtonFocused ?
+ 'WebViewInteractiveTest.WebViewButtonWasFocused' :
+ 'WebViewInteractiveTest.WebViewButtonWasNotFocused');
break;
case 'hide-webview':
getWebView().style.visibility = 'hidden';
« no previous file with comments | « chrome/test/data/extensions/platform_apps/web_view/focus_visibility/window.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698