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

Unified Diff: chrome/test/media_router/resources/common.js

Issue 2820433003: [Presentation API] Add browser tests for 1-UA mode (Closed)
Patch Set: fix android test failures Created 3 years, 8 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 9e69d91a62379ffd824128fc7e2f96760ca34590..0e61e985c97c16da52b2b0450e4142fc87ae958d 100644
--- a/chrome/test/media_router/resources/common.js
+++ b/chrome/test/media_router/resources/common.js
@@ -11,13 +11,21 @@ var startSessionPromise = null;
var startedConnection = null;
var reconnectedSession = null;
var presentationUrl = null;
-if (window.location.href.indexOf('__is_android__=true') >= 0) {
+let params = (new URL(window.location.href)).searchParams;
+
+if (params.get('__is_android__') == 'true') {
// For android, "google.com/cast" is required in presentation URL.
// TODO(zqzhang): this requirement may be removed in the future.
presentationUrl = "https://google.com/cast#__castAppId__=CCCCCCCC/";
+} else if (params.get('__oneUA__') == 'true') {
+ presentationUrl =
+ "presentation_receiver.html#__testprovider__=true&__oneUA__=true";
+} else if (params.get('__oneUANoReceiver__') == 'true') {
+ presentationUrl = "https://www.google.com#__testprovider__=true&__oneUA__=true";
} else {
presentationUrl = "http://www.google.com/#__testprovider__=true";
}
+
var startSessionRequest = new PresentationRequest([presentationUrl]);
var defaultRequestSessionId = null;
var lastExecutionResult = null;
@@ -226,6 +234,26 @@ function sendMessageAndExpectResponse(message) {
}
/**
+ * Sends 'close' to receiver page, and expects receiver page closing
+ * the connection.
+ */
+function initiateCloseFromReceiverPage() {
+ if (!startedConnection) {
+ sendResult(false, 'startedConnection does not exist.');
+ return;
+ }
+ startedConnection.onclose = (event) => {
+ const reason = event.reason;
+ if (reason != 'closed') {
+ sendResult(false, 'Unexpected close reason: ' + reason);
+ return;
+ }
+ sendResult(true, '');
+ };
+ startedConnection.send('close');
+}
+
+/**
* Reconnects to |sessionId| and verifies that it succeeds.
* @param {!string} sessionId ID of session to reconnect.
*/

Powered by Google App Engine
This is Rietveld 408576698