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

Side by Side Diff: chrome/test/media_router/resources/common.js

Issue 2634213002: [Media Router] Add integration browser tests (Closed)
Patch Set: Address Mark's comments Created 3 years, 10 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 /** 1 /**
2 * Copyright 2015 The Chromium Authors. All rights reserved. 2 * Copyright 2015 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 * 5 *
6 * @fileoverview Common APIs for presentation integration tests. 6 * @fileoverview Common APIs for presentation integration tests.
7 * 7 *
8 */ 8 */
9 9
10 var startSessionPromise = null; 10 var startSessionPromise = null;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 if (startedConnection) { 133 if (startedConnection) {
134 startedConnection.onterminate = function() { 134 startedConnection.onterminate = function() {
135 sendResult(true, ''); 135 sendResult(true, '');
136 }; 136 };
137 startedConnection.terminate(); 137 startedConnection.terminate();
138 } else { 138 } else {
139 sendResult(false, 'startedConnection does not exist.'); 139 sendResult(false, 'startedConnection does not exist.');
140 } 140 }
141 } 141 }
142 142
143 /**
144 * Closes |startedConnection| and waits for its onclose event.
145 */
146 function closeSessionAndWaitForStateChange() {
mark a. foltz 2017/02/09 23:29:59 closeConnectionAndWaitForStateChange
takumif 2017/02/14 19:11:48 Done. Should all uses of "session" in this file be
mark a. foltz 2017/02/15 00:41:27 Ideally they should, but don't worry about mass re
takumif 2017/02/18 20:44:05 Acknowledged.
147 if (startedConnection) {
148 if (startedConnection.state == 'closed') {
149 sendResult(false, 'startedConnection is unexpectedly closed.');
150 }
151 startedConnection.onclose = function() {
152 sendResult(true, '');
153 };
154 startedConnection.close();
155 } else {
156 sendResult(false, 'startedConnection does not exist.');
157 }
158 }
159
160 /**
161 * Sends a message to |startedConnection| and expects InvalidStateError to be
162 * thrown. Requires |startedConnection.state| to not equal |initialState|.
163 */
164 function checkSendMessageFailed(initialState) {
165 if (!startedConnection) {
166 sendResult(false, 'startedConnection does not exist.');
167 return;
168 }
169 if (startedConnection.state != initialState) {
170 sendResult(false, 'startedConnection.state is "' + startedConnection.state +
171 '", but we expected "' + initialState + '".');
172 return;
173 }
174
175 try {
176 startedConnection.send('test message');
177 } catch (e) {
178 if (e.name == 'InvalidStateError') {
179 sendResult(true, '');
180 } else {
181 sendResult(false, 'Got an unexpected error: ' + e.name);
182 }
183 }
184 sendResult(false, 'Expected InvalidStateError but it was never thrown.');
185 }
143 186
144 /** 187 /**
145 * Sends a message, and expects the connection to close on error. 188 * Sends a message, and expects the connection to close on error.
146 */ 189 */
147 function sendMessageAndExpectConnectionCloseOnError() { 190 function sendMessageAndExpectConnectionCloseOnError() {
148 if (!startedConnection) { 191 if (!startedConnection) {
149 sendResult(false, 'startedConnection does not exist.'); 192 sendResult(false, 'startedConnection does not exist.');
150 return; 193 return;
151 } 194 }
152 startedConnection.onclose = function(event) { 195 startedConnection.onclose = function(event) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 passed: passed, 275 passed: passed,
233 errorMessage: errorMessage 276 errorMessage: errorMessage
234 })); 277 }));
235 } else { 278 } else {
236 lastExecutionResult = JSON.stringify({ 279 lastExecutionResult = JSON.stringify({
237 passed: passed, 280 passed: passed,
238 errorMessage: errorMessage 281 errorMessage: errorMessage
239 }); 282 });
240 } 283 }
241 } 284 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698