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

Side by Side Diff: chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen/main.js

Issue 306823002: Flip --enable-apps-show-on-first-paint flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tests Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 chrome.app.runtime.onLaunched.addListener(function() { 5 chrome.app.runtime.onLaunched.addListener(function() {
6 chrome.app.window.create('main.html', {}, function(win) { 6 chrome.app.window.create('main.html', {}, function(win) {
7 // The following key events handler will prevent the default behavior for 7 win.onWindowFirstShown.addListener(function() {
8 // the ESC key, thus will prevent the ESC key to leave fullscreen. 8 // The following key events handler will prevent the default behavior for
9 win.contentWindow.document.addEventListener('keydown', function(e) { 9 // the ESC key, thus will prevent the ESC key to leave fullscreen.
10 e.preventDefault(); 10 win.contentWindow.document.addEventListener('keydown', function(e) {
11 }); 11 e.preventDefault();
12 win.contentWindow.document.addEventListener('keyup', function(e) { 12 });
13 e.preventDefault(); 13 win.contentWindow.document.addEventListener('keyup', function(e) {
14 }); 14 e.preventDefault();
15
16 chrome.test.sendMessage('Launched', function(reply) {
17 var doc = win.contentWindow.document;
18 doc.addEventListener('keydown', function(e) {
19 if (e.keyCode != 90) // 'z'
20 return;
21 chrome.test.sendMessage('KeyReceived');
22 }); 15 });
23 16
24 switch (reply) { 17 chrome.test.sendMessage('Launched', function(reply) {
25 case 'window': 18 var doc = win.contentWindow.document;
26 doc.addEventListener('keydown', function(e) { 19 doc.addEventListener('keydown', function(e) {
27 if (e.keyCode != 66) // 'b' 20 if (e.keyCode != 90) // 'z'
28 return; 21 return;
29 doc.removeEventListener('keydown', arguments.callee); 22 chrome.test.sendMessage('KeyReceived');
30 // We do one trip to the event loop to increase the chances that 23 });
31 // fullscreen could have been left before the message is received.
32 setTimeout(function() {
33 chrome.test.sendMessage('B_KEY_RECEIVED');
34 });
35 });
36 win.fullscreen();
37 break;
38 24
39 case 'dom': 25 switch (reply) {
40 doc.addEventListener('keydown', function() { 26 case 'window':
41 doc.removeEventListener('keydown', arguments.callee);
42
43 doc.addEventListener('keydown', function(e) { 27 doc.addEventListener('keydown', function(e) {
44 if (e.keyCode != 66) // 'b' 28 if (e.keyCode != 66) // 'b'
45 return; 29 return;
46 doc.removeEventListener('keydown', arguments.callee); 30 doc.removeEventListener('keydown', arguments.callee);
47 // We do one trip to the event loop to increase the chances that 31 // We do one trip to the event loop to increase the chances that
48 // fullscreen could have been left before the message is received. 32 // fullscreen could have been left before the message is received.
49 setTimeout(function() { 33 setTimeout(function() {
50 chrome.test.sendMessage('B_KEY_RECEIVED'); 34 chrome.test.sendMessage('B_KEY_RECEIVED');
51 }); 35 });
52 }); 36 });
37 win.fullscreen();
38 break;
53 39
54 doc.body.webkitRequestFullscreen(); 40 case 'dom':
55 }); 41 doc.addEventListener('keydown', function() {
56 break; 42 doc.removeEventListener('keydown', arguments.callee);
57 } 43
44 doc.addEventListener('keydown', function(e) {
45 if (e.keyCode != 66) // 'b'
46 return;
47 doc.removeEventListener('keydown', arguments.callee);
48 // We do one trip to the event loop to increase the chances that
49 // fullscreen could have been left before the message is
50 // received.
51 setTimeout(function() {
52 chrome.test.sendMessage('B_KEY_RECEIVED');
53 });
54 });
55
56 doc.body.webkitRequestFullscreen();
57 });
58 break;
59 }
60 });
58 }); 61 });
59 }); 62 });
60 }); 63 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698