Index: chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen_old/main.js |
diff --git a/chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen_old/main.js b/chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen_old/main.js |
index 2a5bebdd607e96974cea84f2a46f459ece749bd4..07a74b2fb0eb0090919ba8cb10889024bf8ac9d9 100644 |
--- a/chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen_old/main.js |
+++ b/chrome/test/data/extensions/platform_apps/prevent_leave_fullscreen_old/main.js |
@@ -4,42 +4,26 @@ |
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; |
- doc.addEventListener('keydown', function(e) { |
- if (e.keyCode != 90) // 'z' |
- return; |
- chrome.test.sendMessage('KeyReceived'); |
+ win.onWindowFirstShown.addListener(function() { |
+ // 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(); |
}); |
- 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); |
+ chrome.test.sendMessage('Launched', function(reply) { |
+ var doc = win.contentWindow.document; |
+ doc.addEventListener('keydown', function(e) { |
+ if (e.keyCode != 90) // 'z' |
+ return; |
+ chrome.test.sendMessage('KeyReceived'); |
+ }); |
+ switch (reply) { |
+ case 'window': |
doc.addEventListener('keydown', function(e) { |
if (e.keyCode != 66) // 'b' |
return; |
@@ -50,11 +34,30 @@ chrome.app.runtime.onLaunched.addListener(function() { |
chrome.test.sendMessage('B_KEY_RECEIVED'); |
}); |
}); |
+ win.fullscreen(); |
+ break; |
- doc.body.webkitRequestFullscreen(); |
- }); |
- 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; |
+ } |
+ }); |
}); |
}); |
}); |