Index: chrome/test/data/extensions/platform_apps/web_view/focus/guest.html |
diff --git a/chrome/test/data/extensions/platform_apps/web_view/focus/guest.html b/chrome/test/data/extensions/platform_apps/web_view/focus/guest.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..956293278f633906706d1cf9add89a113e5e8811 |
--- /dev/null |
+++ b/chrome/test/data/extensions/platform_apps/web_view/focus/guest.html |
@@ -0,0 +1,44 @@ |
+<!-- |
+ * 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. |
+--> |
+<html> |
+ <head> |
+ <script type="text/javascript"> |
+ // A guest that monitors focus. |
+ // Notifies the embedder about changes in focus via postMessage. |
+ // Note that the embedder has to initiate a postMessage first so that |
+ // the guest has a reference to the embedder's window. |
+ |
+ // The window reference of the embedder to send post message reply. |
+ var embedderWindowChannel = null; |
+ var embedderTestName = ''; |
+ |
+ var notifyEmbedder = function(msg_array) { |
+ embedderWindowChannel.postMessage(JSON.stringify(msg_array), '*'); |
+ }; |
+ |
+ var onPostMessageReceived = function(e) { |
+ embedderWindowChannel = e.source; |
+ var data = JSON.parse(e.data); |
+ if (data[0] == 'create-channel') { |
+ embedderTestName = data[1]; |
+ notifyEmbedder(['channel-created']); |
+ } |
+ }; |
+ window.addEventListener('message', onPostMessageReceived, false); |
+ |
+ window.addEventListener('focus', function(e) { |
+ notifyEmbedder(['focused', embedderTestName]); |
+ }); |
+ |
+ window.addEventListener('blur', function(e) { |
+ notifyEmbedder(['blurred', embedderTestName]); |
+ }); |
+ </script> |
+ </head> |
+ <body> |
+ <div>This is a guest that monitors focus.</div> |
+ </body> |
+</html> |