Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / tab_capture / fullscreen_test.js
blob7c54fe3d93594abcc9fc9bcb6b9f32bdbbb6d61e
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
3 // found in the LICENSE file.
5 window.addEventListener('load', function() {
6 document.body.onclick = function toggleBodyFullscreen() {
7 if (document.fullscreenElement || document.webkitFullscreenElement) {
8 if (document.exitFullscreen)
9 document.exitFullscreen();
10 else if (document.webkitExitFullscreen)
11 document.webkitExitFullscreen();
12 else
13 chrome.test.assertTrue(!"HTML5 Fullscreen API missing");
14 } else {
15 if (document.body.requestFullscreen)
16 document.body.requestFullscreen();
17 else if (document.body.webkitRequestFullscreen)
18 document.body.webkitRequestFullscreen();
19 else
20 chrome.test.assertTrue(!"HTML5 Fullscreen API missing");
23 });
25 var mediaStream = null;
26 var events = [];
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();
40 if (info.fullscreen)
41 chrome.test.sendMessage('entered_fullscreen');
43 });
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 });