| Index: chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen/main.js
|
| diff --git a/chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen/main.js b/chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen/main.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e20671028d9b9af15338b48497132cb29a4e2fb0
|
| --- /dev/null
|
| +++ b/chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen/main.js
|
| @@ -0,0 +1,55 @@
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +chrome.app.runtime.onLaunched.addListener(function() {
|
| + chrome.app.window.create('main.html', {}, function(win) {
|
| + // The following key events handler will prevent the default behavior for
|
| + // the ESC key, thus will prevent the ESC key to leave fullscreen.
|
| + win.contentWindow.document.addEventListener('keydown', function(e) {
|
| + e.preventDefault();
|
| + });
|
| + win.contentWindow.document.addEventListener('keyup', function(e) {
|
| + e.preventDefault();
|
| + });
|
| +
|
| + chrome.test.sendMessage('Launched', function(reply) {
|
| + var doc = win.contentWindow.document;
|
| +
|
| + switch (reply) {
|
| + case 'window':
|
| + doc.addEventListener('keydown', function(e) {
|
| + if (e.keyCode != 66) // 'b'
|
| + return;
|
| + doc.removeEventListener('keydown', arguments.callee);
|
| + // We do one trip to the event loop to increase the chances that
|
| + // fullscreen could have been left before the message is received.
|
| + setTimeout(function() {
|
| + chrome.test.sendMessage('B_KEY_RECEIVED');
|
| + });
|
| + });
|
| + win.fullscreen();
|
| + break;
|
| +
|
| + case 'dom':
|
| + doc.addEventListener('keydown', function() {
|
| + doc.removeEventListener('keydown', arguments.callee);
|
| +
|
| + doc.addEventListener('keydown', function(e) {
|
| + if (e.keyCode != 66) // 'b'
|
| + return;
|
| + doc.removeEventListener('keydown', arguments.callee);
|
| + // We do one trip to the event loop to increase the chances that
|
| + // fullscreen could have been left before the message is received.
|
| + setTimeout(function() {
|
| + chrome.test.sendMessage('B_KEY_RECEIVED');
|
| + });
|
| + });
|
| +
|
| + doc.body.webkitRequestFullscreen();
|
| + });
|
| + break;
|
| + }
|
| + });
|
| + });
|
| +});
|
|
|