| OLD | NEW |
| 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * @suppress {checkTypes} By default, JSCompile is not run on test files. | 7 * @suppress {checkTypes} By default, JSCompile is not run on test files. |
| 8 * However, you can modify |remoting_webapp_files.gypi| locally to include | 8 * However, you can modify |remoting_webapp_files.gypi| locally to include |
| 9 * the test in the package to expedite local development. This suppress | 9 * the test in the package to expedite local development. This suppress |
| 10 * is here so that JSCompile won't complain. | 10 * is here so that JSCompile won't complain. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 * | 37 * |
| 38 * You will then invoke the test in C++ by calling: | 38 * You will then invoke the test in C++ by calling: |
| 39 * | 39 * |
| 40 * RunJavaScriptTest(web_content, "My_Test", "{" | 40 * RunJavaScriptTest(web_content, "My_Test", "{" |
| 41 * "pin: '123123'" | 41 * "pin: '123123'" |
| 42 * "}"); | 42 * "}"); |
| 43 */ | 43 */ |
| 44 | 44 |
| 45 'use strict'; | 45 'use strict'; |
| 46 | 46 |
| 47 var browserTest = {}; | 47 var browserTest = browserTest || {}; |
| 48 | 48 |
| 49 browserTest.init = function() { | 49 browserTest.init = function() { |
| 50 // The domAutomationController is used to communicate progress back to the | 50 // The domAutomationController is used to communicate progress back to the |
| 51 // C++ calling code. It will only exist if chrome is run with the flag | 51 // C++ calling code. It will only exist if chrome is run with the flag |
| 52 // --dom-automation. It is stubbed out here so that browser test can be run | 52 // --dom-automation. It is stubbed out here so that browser test can be run |
| 53 // under the regular app. | 53 // under the regular app. |
| 54 browserTest.automationController_ = window.domAutomationController || { | 54 browserTest.automationController_ = window.domAutomationController || { |
| 55 send: function(json) { | 55 send: function(json) { |
| 56 var result = JSON.parse(json); | 56 var result = JSON.parse(json); |
| 57 if (result.succeeded) { | 57 if (result.succeeded) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 browserTest.pass = function() { | 100 browserTest.pass = function() { |
| 101 browserTest.automationController_.send(JSON.stringify({ | 101 browserTest.automationController_.send(JSON.stringify({ |
| 102 succeeded: true, | 102 succeeded: true, |
| 103 error_message: '', | 103 error_message: '', |
| 104 stack_trace: '' | 104 stack_trace: '' |
| 105 })); | 105 })); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 browserTest.clickOnControl = function(id) { | 108 browserTest.clickOnControl = function(id) { |
| 109 var element = document.getElementById(id); | 109 var element = document.getElementById(id); |
| 110 browserTest.expect(element); | 110 browserTest.expect(element, 'No such element: ' + id); |
| 111 element.click(); | 111 element.click(); |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 /** @enum {number} */ | |
| 115 browserTest.Timeout = { | |
| 116 NONE: -1, | |
| 117 DEFAULT: 5000 | |
| 118 }; | |
| 119 | |
| 120 browserTest.onUIMode = function(expectedMode, opt_timeout) { | 114 browserTest.onUIMode = function(expectedMode, opt_timeout) { |
| 121 if (expectedMode == remoting.currentMode) { | 115 if (expectedMode == remoting.currentMode) { |
| 122 // If the current mode is the same as the expected mode, return a fulfilled | 116 // If the current mode is the same as the expected mode, return a fulfilled |
| 123 // promise. For some reason, if we fulfill the promise in the same | 117 // promise. For some reason, if we fulfill the promise in the same |
| 124 // callstack, V8 will assert at V8RecursionScope.h(66) with | 118 // callstack, V8 will assert at V8RecursionScope.h(66) with |
| 125 // ASSERT(!ScriptForbiddenScope::isScriptForbidden()). | 119 // ASSERT(!ScriptForbiddenScope::isScriptForbidden()). |
| 126 // To avoid the assert, execute the callback in a different callstack. | 120 // To avoid the assert, execute the callback in a different callstack. |
| 127 return base.Promise.sleep(0); | 121 return base.Promise.sleep(0); |
| 128 } | 122 } |
| 129 | 123 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 // Called by Browser Test in C++ | 317 // Called by Browser Test in C++ |
| 324 browserTest.ensureRemoteConnectionEnabled = function(pin) { | 318 browserTest.ensureRemoteConnectionEnabled = function(pin) { |
| 325 browserTest.ensureHostStartedWithPIN(pin).then(function(){ | 319 browserTest.ensureHostStartedWithPIN(pin).then(function(){ |
| 326 browserTest.automationController_.send(true); | 320 browserTest.automationController_.send(true); |
| 327 }, function(errorMessage){ | 321 }, function(errorMessage){ |
| 328 console.error(errorMessage); | 322 console.error(errorMessage); |
| 329 browserTest.automationController_.send(false); | 323 browserTest.automationController_.send(false); |
| 330 }); | 324 }); |
| 331 }; | 325 }; |
| 332 | 326 |
| 333 browserTest.init(); | 327 browserTest.init(); |
| OLD | NEW |