Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 window.addEventListener('load', function() { | 5 window.addEventListener('load', () => { |
| 6 document.body.onclick = function toggleBodyFullscreen() { | 6 // Register the fullscreen change listener. This is used to determine when to |
| 7 // signal the C++ side of this test that the document has entered/exited | |
| 8 // fullscreen. NOTE: It's very important NOT to use the | |
| 9 // tabCapture.onStatusChanged listener to signal the C++ side of this test | |
| 10 // because sometimes the document's fullscreen state change lags behind what | |
| 11 // the tabCapture API knows about the browser window's fullscreen state. | |
| 12 // Otherwise, the C++ side of this test might proceed out-of-sync and fail. | |
| 13 // http://crbug.com/675851 | |
| 14 if (document.fullscreenEnabled) { | |
| 15 document.onfullscreenchange = () => { | |
| 16 if (!!document.fullscreenElement) | |
|
xjz
2017/01/03 18:14:06
ooc: Is this explicit conversion required? Can it
miu
2017/01/03 20:53:35
Done.
| |
| 17 chrome.test.sendMessage('entered_fullscreen'); | |
| 18 }; | |
| 19 } else if (document.webkitFullscreenEnabled) { | |
| 20 document.onwebkitfullscreenchange = () => { | |
| 21 if (!!document.webkitFullscreenElement) | |
|
xjz
2017/01/03 18:14:06
ditto: if (document.webkitFullscreenElement)?
miu
2017/01/03 20:53:35
Done.
| |
| 22 chrome.test.sendMessage('entered_fullscreen'); | |
| 23 }; | |
| 24 } else { | |
| 25 chrome.test.assertTrue(!'HTML5 Fullscreen API missing'); | |
| 26 } | |
| 27 | |
| 28 // Register an onclick listener that toggles the entire document into or | |
| 29 // out-of fullscreen mode. The clicks are generated by the C++ side of this | |
| 30 // test. | |
| 31 document.documentElement.onclick = () => { | |
| 7 if (document.fullscreenElement || document.webkitFullscreenElement) { | 32 if (document.fullscreenElement || document.webkitFullscreenElement) { |
| 8 if (document.exitFullscreen) | 33 if (document.exitFullscreen) |
| 9 document.exitFullscreen(); | 34 document.exitFullscreen(); |
| 10 else if (document.webkitExitFullscreen) | 35 else if (document.webkitExitFullscreen) |
| 11 document.webkitExitFullscreen(); | 36 document.webkitExitFullscreen(); |
| 12 else | 37 else |
| 13 chrome.test.assertTrue(!"HTML5 Fullscreen API missing"); | 38 chrome.test.assertTrue(!'HTML5 Fullscreen API missing'); |
| 14 } else { | 39 } else { |
| 15 if (document.body.requestFullscreen) | 40 if (document.documentElement.requestFullscreen) |
| 16 document.body.requestFullscreen(); | 41 document.documentElement.requestFullscreen(); |
| 17 else if (document.body.webkitRequestFullscreen) | 42 else if (document.documentElement.webkitRequestFullscreen) |
| 18 document.body.webkitRequestFullscreen(); | 43 document.documentElement.webkitRequestFullscreen(); |
| 19 else | 44 else |
| 20 chrome.test.assertTrue(!"HTML5 Fullscreen API missing"); | 45 chrome.test.assertTrue(!'HTML5 Fullscreen API missing'); |
| 21 } | 46 } |
| 22 }; | 47 }; |
| 48 | |
| 49 let mediaStream = null; | |
| 50 const events = []; | |
| 51 | |
| 52 // Register the tab capture status change listener, which records the changes | |
| 53 // to fullscreen state according to the tab capture API implementation. Once | |
| 54 // there are three changes, check the results and succeed() the test. | |
| 55 chrome.tabCapture.onStatusChanged.addListener(info => { | |
| 56 if (info.status == 'active') { | |
| 57 events.push(info.fullscreen); | |
| 58 if (events.length == 3) { | |
| 59 mediaStream.getVideoTracks()[0].stop(); | |
| 60 mediaStream.getAudioTracks()[0].stop(); | |
| 61 chrome.test.assertFalse(events[0]); | |
| 62 chrome.test.assertTrue(events[1]); | |
| 63 chrome.test.assertFalse(events[2]); | |
| 64 chrome.test.succeed(); | |
| 65 } | |
| 66 } | |
| 67 }); | |
| 68 | |
| 69 // Now that all listeners are in-place, start tab capture. Once tab capture is | |
| 70 // running, notify the C++ side of this test that it may commence with the | |
| 71 // "fullscreen toggle mouse clicks." | |
| 72 chrome.tabCapture.capture({audio: true, video: true}, stream => { | |
| 73 chrome.test.assertTrue(!!stream); | |
| 74 mediaStream = stream; | |
| 75 chrome.test.notifyPass(); | |
| 76 chrome.test.sendMessage('tab_capture_started'); | |
| 77 }); | |
| 23 }); | 78 }); |
| 24 | |
| 25 var mediaStream = null; | |
| 26 var events = []; | |
| 27 | |
| 28 chrome.tabCapture.onStatusChanged.addListener(function(info) { | |
| 29 if (info.status == 'active') { | |
| 30 events.push(info.fullscreen); | |
| 31 if (events.length == 3) { | |
| 32 chrome.test.assertFalse(events[0]); | |
| 33 chrome.test.assertTrue(events[1]); | |
| 34 chrome.test.assertFalse(events[2]); | |
| 35 mediaStream.getVideoTracks()[0].stop(); | |
| 36 mediaStream.getAudioTracks()[0].stop(); | |
| 37 chrome.test.succeed(); | |
| 38 } | |
| 39 | |
| 40 if (info.fullscreen) | |
| 41 chrome.test.sendMessage('entered_fullscreen'); | |
| 42 } | |
| 43 }); | |
| 44 | |
| 45 chrome.tabCapture.capture({audio: true, video: true}, function(stream) { | |
| 46 chrome.test.assertTrue(!!stream); | |
| 47 mediaStream = stream; | |
| 48 chrome.test.notifyPass(); | |
| 49 chrome.test.sendMessage('tab_capture_started'); | |
| 50 }); | |
| OLD | NEW |