Chromium Code Reviews| 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..0cb55c8095b241eca37cf09883847d4f35527c79 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) { |
| +var pageUrl = window.location.href; |
| + |
| +if (pageUrl.indexOf('__is_android__=true') >= 0) { |
|
mark a. foltz
2017/04/18 01:03:44
Can you use URL.searchParams to parse the URL inst
zhaobin
2017/04/18 03:17:10
Done.
|
| // 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 (pageUrl.indexOf('__oneUA__=true') >= 0) { |
| + presentationUrl = |
| + "presentation_receiver.html#__testprovider__=true&__oneUA__=true"; |
| +} else if (pageUrl.indexOf('__oneUANoReceiver__=true') >= 0) { |
| + 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 = function(event) { |
|
mark a. foltz
2017/04/18 01:03:44
Slight preference for arrow function syntax: (even
zhaobin
2017/04/18 03:17:10
Done.
|
| + var reason = event.reason; |
|
mark a. foltz
2017/04/18 01:03:44
s/var/const/
zhaobin
2017/04/18 03:17:10
Done.
|
| + 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. |
| */ |