Index: chrome/test/data/prerender/prerender_plugin_power_saver.html |
diff --git a/chrome/test/data/prerender/prerender_plugin_power_saver.html b/chrome/test/data/prerender/prerender_plugin_power_saver.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..18cb87e9de0d497dff7656733b68c7ad5ec1cc4e |
--- /dev/null |
+++ b/chrome/test/data/prerender/prerender_plugin_power_saver.html |
@@ -0,0 +1,54 @@ |
+<html> |
+<!-- |
+This test checks the interaction between prerendering and the Plugin Power Saver |
+feature. It expects: |
+ - The plugin is not loaded during prerender. |
+ - It is loaded (briefly) during the preroll of the plugin. |
+ - It is replaced by the power saver placeholder after the preroll is over. |
+ |
+This test relies on the Pepper plugin (but not the placeholder) implementing |
+the postMessage() function on the plugin object. |
+--> |
+<head> |
+<title>Prerender Plugin Delay Loading</title> |
+ |
+<script> |
+// Make sure plugin was not loaded while prerendering. |
+function DidPrerenderPass() { |
+ // |plugin| should be the blocked plugin placeholder, rather than the |
+ // test plugin. |
+ var plugin = window.document.getElementById('plugin'); |
+ return plugin.postMessage === undefined; |
+} |
+ |
+// Make sure the plugin briefly exists, then is replaced with a placeholder. |
+function AwaitPluginPrerollAndPlaceholder() { |
+ var plugin = window.document.getElementById('plugin'); |
+ function handleEvent(event) { |
+ // We should eventually get a message indicating that the plugin has been |
+ // throttled and replaced with a static placeholder. |
+ if (event.data.isThrottled && event.data.isHiddenForPlaceholder) { |
+ plugin.removeEventListener('message', handleEvent); |
+ window.domAutomationController.send(true); |
+ } |
+ } |
+ |
+ plugin.addEventListener('message', handleEvent); |
+ |
+ // If postMessage is not defined, the plugin is still the initial placeholder. |
+ // When the real plugin loads, we will still get the initial power saver |
+ // status notifications. |
+ if (plugin.postMessage !== undefined) { |
+ plugin.postMessage('getPowerSaverStatus'); |
+ } |
+} |
+</script> |
+ |
+</head> |
+<body> |
+ |
+<object id="plugin" type="application/x-ppapi-tests" height='100' width='100'> |
+</object> |
+ |
+</body> |
+</html> |