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

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: Address comment from kenrb@ 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
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | content/content_renderer.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
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
30 var onInputState = {fired: false, value: ''}; 18 var onInputState = {fired: false, value: ''};
31 // Waits for oninput event to fire on |inputElement1|. 19 // Waits for oninput event to fire on |inputElement1|.
32 // Upon receiving the event, we ping back the embedder with the value of 20 // Upon receiving the event, we ping back the embedder with the value of
33 // the textbox. 21 // the textbox.
34 var waitForOnInput = function() { 22 var waitForOnInput = function() {
35 var inputElement1 = document.querySelector('input'); 23 var inputElement1 = document.querySelector('input');
36 LOG('inputElement1: ' + inputElement1); 24 LOG('inputElement1: ' + inputElement1);
37 if (onInputState.fired) { 25 if (onInputState.fired) {
38 onInputFired(); 26 sendMessage(['response-waitForOnInput', onInputState.value]);
39 } else { 27
40 waitingForInput = true; 28 onInputState.fired = false;
29 if (inputElement1.value == 'InputTest456') {
30 // Prepare for next step, step 3.
31 inputElement1.value = '';
32 }
41 } 33 }
42 }; 34 };
43 35
44 // Waits for the first textbox element to be focused. 36 // Waits for the first textbox element to be focused.
45 var waitForFocus = function() { 37 var waitForFocus = function() {
46 inputElement1 = document.createElement('input'); 38 inputElement1 = document.createElement('input');
47 inputElement1.id = 'input1'; 39 inputElement1.id = 'input1';
48 inputElement1.oninput = function() { 40 inputElement1.oninput = function() {
49 LOG('inputElement1.oninput: ' + inputElement1.value); 41 LOG('inputElement1.oninput: ' + inputElement1.value);
50 onInputState.fired = true; 42 onInputState.fired = true;
51 onInputState.value = inputElement1.value; 43 onInputState.value = inputElement1.value;
52 if (waitingForInput) {
53 onInputFired();
54 }
55 }; 44 };
56 var inputElement1FocusListener = function() { 45 var inputElement1FocusListener = function() {
57 LOG('inputElement1.focus'); 46 LOG('inputElement1.focus');
58 inputElement1.removeEventListener('focus', inputElement1FocusListener); 47 inputElement1.removeEventListener('focus', inputElement1FocusListener);
59 sendMessage(['response-seenFocus']); 48 sendMessage(['response-seenFocus']);
60 }; 49 };
61 inputElement1.addEventListener('focus', inputElement1FocusListener); 50 inputElement1.addEventListener('focus', inputElement1FocusListener);
62 document.body.appendChild(inputElement1); 51 document.body.appendChild(inputElement1);
63 52
64 inputElement2 = document.createElement('input'); 53 inputElement2 = document.createElement('input');
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 }; 92 };
104 inputElement2.addEventListener('focus', onInputElement2Focused); 93 inputElement2.addEventListener('focus', onInputElement2Focused);
105 94
106 inputElement2.focus(); 95 inputElement2.focus();
107 } else if (data[0] == 'request-valueAfterExtendSelection') { 96 } else if (data[0] == 'request-valueAfterExtendSelection') {
108 sendMessage(['response-valueAfterExtendSelection', inputElement1.value]); 97 sendMessage(['response-valueAfterExtendSelection', inputElement1.value]);
109 } else if (data[0] == 'request-focus-again') { 98 } else if (data[0] == 'request-focus-again') {
110 waitForFocusAgain(); 99 waitForFocusAgain();
111 } 100 }
112 }); 101 });
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | content/content_renderer.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698