Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 g_webview = null; | 5 var g_webview = null; |
| 6 var embedder = {}; | 6 var embedder = {}; |
| 7 var seenFocusCount = 0; | 7 var seenFocusCount = 0; |
| 8 embedder.tests = {}; | 8 embedder.tests = {}; |
| 9 embedder.guestURL = | 9 embedder.guestURL = |
| 10 'data:text/html,<html><body>Guest<body></html>'; | 10 'data:text/html,<html><body>Guest<body></html>'; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 window.console.log('window.runCommand: ' + command); | 26 window.console.log('window.runCommand: ' + command); |
| 27 switch (command) { | 27 switch (command) { |
| 28 case 'testFocusTracksEmbedderRunNextStep': | 28 case 'testFocusTracksEmbedderRunNextStep': |
| 29 testFocusTracksEmbedderRunNextStep(); | 29 testFocusTracksEmbedderRunNextStep(); |
| 30 break; | 30 break; |
| 31 case 'testInputMethodRunNextStep': | 31 case 'testInputMethodRunNextStep': |
| 32 testInputMethodRunNextStep(opt_step); | 32 testInputMethodRunNextStep(opt_step); |
| 33 break; | 33 break; |
| 34 case 'testFocusRestoredRunNextStep': | 34 case 'testFocusRestoredRunNextStep': |
| 35 testFocusRestoredRunNextStep(opt_step); | 35 testFocusRestoredRunNextStep(opt_step); |
| 36 break; | |
| 37 case 'testKeyboardFocusRunNextStep': | |
| 38 testKeyboardFocusRunNextStep(opt_step); | |
| 39 break; | |
| 36 default: | 40 default: |
| 37 embedder.test.fail(); | 41 embedder.test.fail(); |
| 38 } | 42 } |
| 39 }; | 43 }; |
| 40 // window.* exported functions end. | 44 // window.* exported functions end. |
| 41 | 45 |
| 42 var LOG = function(msg) { | 46 var LOG = function(msg) { |
| 43 window.console.log(msg); | 47 window.console.log(msg); |
| 44 }; | 48 }; |
| 45 | 49 |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 webview.blur(); | 386 webview.blur(); |
| 383 }, 'blurred', function() { | 387 }, 'blurred', function() { |
| 384 if (seenResponse) { | 388 if (seenResponse) { |
| 385 return; | 389 return; |
| 386 } | 390 } |
| 387 seenResponse = true; | 391 seenResponse = true; |
| 388 embedder.test.succeed(); | 392 embedder.test.succeed(); |
| 389 }); | 393 }); |
| 390 } | 394 } |
| 391 | 395 |
| 396 function testKeyboardFocus() { | |
| 397 | |
|
alexmos
2016/06/07 22:03:43
no blank line
avallee
2016/06/15 13:32:10
Done.
| |
| 398 embedder.testFocus_(function(webview){ | |
|
alexmos
2016/06/07 22:03:43
nit: space before {
avallee
2016/06/15 13:32:10
Done.
| |
| 399 g_webview = webview; | |
| 400 var msg = ['request-createInput']; | |
| 401 webview.contentWindow.postMessage(JSON.stringify(msg), '*'); | |
| 402 chrome.test.sendMessage('TEST_PASSED'); | |
| 403 }, | |
| 404 'response-inputClicked', | |
| 405 function() { | |
| 406 chrome.test.sendMessage('TEST_STEP_PASSED'); | |
| 407 }); | |
| 408 } | |
| 409 | |
| 410 function testKeyboardFocusRunNextStep(expected) { | |
| 411 g_webview.contentWindow.postMessage( | |
| 412 JSON.stringify(['request-getInputValue']), '*'); | |
| 413 | |
| 414 window.addEventListener('message', function(e) { | |
| 415 var data = JSON.parse(e.data); | |
| 416 LOG('send window.message, data: ' + data); | |
| 417 if (data[0] == 'response-inputValue', data[1] == expected) { | |
|
alexmos
2016/06/07 22:03:43
should that comma be &&?
avallee
2016/06/15 13:32:10
Should have been a nested if.
| |
| 418 chrome.test.sendMessage('TEST_STEP_PASSED'); | |
| 419 } else { | |
| 420 chrome.test.sendMessage('TEST_STEP_FAILED'); | |
| 421 } | |
| 422 }); | |
| 423 } | |
| 424 | |
| 392 // This test verifies IME related stuff for guest. | 425 // This test verifies IME related stuff for guest. |
| 393 // | 426 // |
| 394 // Briefly: | 427 // Briefly: |
| 395 // 1) We load a guest, the guest gets initial focus and sends message | 428 // 1) We load a guest, the guest gets initial focus and sends message |
| 396 // back to the embedder. | 429 // back to the embedder. |
| 397 // 2) In InputMethodTestHelper's step 1, we receive some text via cpp, the | 430 // 2) In InputMethodTestHelper's step 1, we receive some text via cpp, the |
| 398 // text is InputTest123, we verify we've seen the change in the guest. | 431 // text is InputTest123, we verify we've seen the change in the guest. |
| 399 // 3) In InputMethodTestHelper's step 2, we expect the text to be changed | 432 // 3) In InputMethodTestHelper's step 2, we expect the text to be changed |
| 400 // to InputTest456, this is done from cpp via committing an IME composition. | 433 // to InputTest456, this is done from cpp via committing an IME composition. |
| 401 // 4) In InputMethodTestHelper's step 3, we have a composition (InputTest789) | 434 // 4) In InputMethodTestHelper's step 3, we have a composition (InputTest789) |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 591 webview.src = embedder.guestURL; | 624 webview.src = embedder.guestURL; |
| 592 } | 625 } |
| 593 | 626 |
| 594 embedder.test.testList = { | 627 embedder.test.testList = { |
| 595 'testAdvanceFocus': testAdvanceFocus, | 628 'testAdvanceFocus': testAdvanceFocus, |
| 596 'testBlurEvent': testBlurEvent, | 629 'testBlurEvent': testBlurEvent, |
| 597 'testFocusBeforeNavigation': testFocusBeforeNavigation, | 630 'testFocusBeforeNavigation': testFocusBeforeNavigation, |
| 598 'testFocusEvent': testFocusEvent, | 631 'testFocusEvent': testFocusEvent, |
| 599 'testFocusTracksEmbedder': testFocusTracksEmbedder, | 632 'testFocusTracksEmbedder': testFocusTracksEmbedder, |
| 600 'testInputMethod': testInputMethod, | 633 'testInputMethod': testInputMethod, |
| 634 'testKeyboardFocus': testKeyboardFocus, | |
| 601 'testFocusRestored': testFocusRestored | 635 'testFocusRestored': testFocusRestored |
| 602 }; | 636 }; |
| 603 | 637 |
| 604 onload = function() { | 638 onload = function() { |
| 605 chrome.test.getConfig(function(config) { | 639 chrome.test.getConfig(function(config) { |
| 606 chrome.test.sendMessage('Launched'); | 640 chrome.test.sendMessage('Launched'); |
| 607 }); | 641 }); |
| 608 }; | 642 }; |
| OLD | NEW |