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

Side by Side Diff: chrome/test/data/extensions/platform_apps/web_view/focus/inject_input_method.js

Issue 376033002: Adding MimeHandlerView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pending-zork-patch2
Patch Set: add switch to control feature, remove a DCHECK from extension_message_filter Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var embedder = null; 5 var embedder = null;
6 var inputElement1; 6 var inputElement1;
7 var inputElement2; 7 var inputElement2;
8 var waitingForBlur = false; 8 var waitingForBlur = false;
9 9
10 var LOG = function(msg) { 10 var LOG = function(msg) {
11 window.console.log(msg); 11 window.console.log(msg);
12 }; 12 };
13 13
14 var sendMessage = function(data) { 14 var sendMessage = function(data) {
15 embedder.postMessage(JSON.stringify(data), '*'); 15 embedder.postMessage(JSON.stringify(data), '*');
16 }; 16 };
17 17
18 var waitingForInput = false;
Fady Samuel 2014/09/04 17:31:07 Why is this here?
lazyboy 2014/09/04 18:59:33 Somehow creeped in from my other CL, thanks for ca
19
20 var onInputFired = function() {
21 sendMessage(['response-waitForOnInput', onInputState.value]);
22 onInputState.fired = false;
23 if (inputElement1.value == 'InputTest456') {
24 // Prepare for next step, step 3.
25 inputElement1.value = '';
26 }
27 waitingForInput = false;
28 };
29
18 var onInputState = {fired: false, value: ''}; 30 var onInputState = {fired: false, value: ''};
19 // Waits for oninput event to fire on |inputElement1|. 31 // Waits for oninput event to fire on |inputElement1|.
20 // Upon receiving the event, we ping back the embedder with the value of 32 // Upon receiving the event, we ping back the embedder with the value of
21 // the textbox. 33 // the textbox.
22 var waitForOnInput = function() { 34 var waitForOnInput = function() {
23 var inputElement1 = document.querySelector('input'); 35 var inputElement1 = document.querySelector('input');
24 LOG('inputElement1: ' + inputElement1); 36 LOG('inputElement1: ' + inputElement1);
25 if (onInputState.fired) { 37 if (onInputState.fired) {
26 sendMessage(['response-waitForOnInput', onInputState.value]); 38 onInputFired();
27 39 } else {
28 onInputState.fired = false; 40 waitingForInput = true;
29 if (inputElement1.value == 'InputTest456') {
30 // Prepare for next step, step 3.
31 inputElement1.value = '';
32 }
33 } 41 }
34 }; 42 };
35 43
36 // Waits for the first textbox element to be focused. 44 // Waits for the first textbox element to be focused.
37 var waitForFocus = function() { 45 var waitForFocus = function() {
38 inputElement1 = document.createElement('input'); 46 inputElement1 = document.createElement('input');
39 inputElement1.id = 'input1'; 47 inputElement1.id = 'input1';
40 inputElement1.oninput = function() { 48 inputElement1.oninput = function() {
41 LOG('inputElement1.oninput: ' + inputElement1.value); 49 LOG('inputElement1.oninput: ' + inputElement1.value);
42 onInputState.fired = true; 50 onInputState.fired = true;
43 onInputState.value = inputElement1.value; 51 onInputState.value = inputElement1.value;
52 if (waitingForInput) {
53 onInputFired();
54 }
44 }; 55 };
45 var inputElement1FocusListener = function() { 56 var inputElement1FocusListener = function() {
46 LOG('inputElement1.focus'); 57 LOG('inputElement1.focus');
47 inputElement1.removeEventListener('focus', inputElement1FocusListener); 58 inputElement1.removeEventListener('focus', inputElement1FocusListener);
48 sendMessage(['response-seenFocus']); 59 sendMessage(['response-seenFocus']);
49 }; 60 };
50 inputElement1.addEventListener('focus', inputElement1FocusListener); 61 inputElement1.addEventListener('focus', inputElement1FocusListener);
51 document.body.appendChild(inputElement1); 62 document.body.appendChild(inputElement1);
52 63
53 inputElement2 = document.createElement('input'); 64 inputElement2 = document.createElement('input');
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 }; 103 };
93 inputElement2.addEventListener('focus', onInputElement2Focused); 104 inputElement2.addEventListener('focus', onInputElement2Focused);
94 105
95 inputElement2.focus(); 106 inputElement2.focus();
96 } else if (data[0] == 'request-valueAfterExtendSelection') { 107 } else if (data[0] == 'request-valueAfterExtendSelection') {
97 sendMessage(['response-valueAfterExtendSelection', inputElement1.value]); 108 sendMessage(['response-valueAfterExtendSelection', inputElement1.value]);
98 } else if (data[0] == 'request-focus-again') { 109 } else if (data[0] == 'request-focus-again') {
99 waitForFocusAgain(); 110 waitForFocusAgain();
100 } 111 }
101 }); 112 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698