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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/media_router/resources/common.js
diff --git a/chrome/test/media_router/resources/common.js b/chrome/test/media_router/resources/common.js
index d7f4241331d94367880232ccb047ccc163c92080..7cbc77578eda68570f40ab115e064e0da52eebc1 100644
--- a/chrome/test/media_router/resources/common.js
+++ b/chrome/test/media_router/resources/common.js
@@ -140,6 +140,49 @@ function terminateSessionAndWaitForStateChange() {
}
}
+/**
+ * Closes |startedConnection| and waits for its onclose event.
+ */
+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.
+ if (startedConnection) {
+ if (startedConnection.state == 'closed') {
+ sendResult(false, 'startedConnection is unexpectedly closed.');
+ }
+ startedConnection.onclose = function() {
+ sendResult(true, '');
+ };
+ startedConnection.close();
+ } else {
+ sendResult(false, 'startedConnection does not exist.');
+ }
+}
+
+/**
+ * Sends a message to |startedConnection| and expects InvalidStateError to be
+ * thrown. Requires |startedConnection.state| to not equal |initialState|.
+ */
+function checkSendMessageFailed(initialState) {
+ if (!startedConnection) {
+ sendResult(false, 'startedConnection does not exist.');
+ return;
+ }
+ if (startedConnection.state != initialState) {
+ sendResult(false, 'startedConnection.state is "' + startedConnection.state +
+ '", but we expected "' + initialState + '".');
+ return;
+ }
+
+ try {
+ startedConnection.send('test message');
+ } catch (e) {
+ if (e.name == 'InvalidStateError') {
+ sendResult(true, '');
+ } else {
+ sendResult(false, 'Got an unexpected error: ' + e.name);
+ }
+ }
+ sendResult(false, 'Expected InvalidStateError but it was never thrown.');
+}
/**
* Sends a message, and expects the connection to close on error.

Powered by Google App Engine
This is Rietveld 408576698