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..1d790c1dc43cfe7411fe97ab80b30f1999a09851 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) { |
| // 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; |
| @@ -212,16 +220,27 @@ function sendMessageAndExpectResponse(message) { |
| sendResult(false, 'startedConnection does not exist.'); |
| return; |
| } |
| - startedConnection.onmessage = function(receivedMessage) { |
| - var expectedResponse = 'Pong: ' + message; |
| - var actualResponse = receivedMessage.data; |
| - if (actualResponse != expectedResponse) { |
| - sendResult(false, 'Expected message: ' + expectedResponse + |
| - ', but got: ' + actualResponse); |
| - return; |
| - } |
| - sendResult(true, ''); |
| - }; |
| + if (message == 'close') { |
|
imcheng
2017/04/17 19:06:44
This is an indirect way to tell presentation_recei
zhaobin
2017/04/17 21:24:07
Done.
|
| + startedConnection.onclose = function(event) { |
| + var reason = event.reason; |
| + if (reason != 'closed') { |
| + sendResult(false, 'Unexpected close reason: ' + reason); |
| + return; |
| + } |
| + sendResult(true, ''); |
| + }; |
| + } else { |
| + startedConnection.onmessage = function(receivedMessage) { |
| + var expectedResponse = 'Pong: ' + message; |
| + var actualResponse = receivedMessage.data; |
| + if (actualResponse != expectedResponse) { |
| + sendResult(false, 'Expected message: ' + expectedResponse + |
| + ', but got: ' + actualResponse); |
| + return; |
| + } |
| + sendResult(true, ''); |
| + }; |
| + } |
| startedConnection.send(message); |
| } |