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

Unified Diff: chrome/test/data/prerender/prerender_plugin_power_saver.html

Issue 1114623002: Plugin Power Saver: Make PPS work well with prerendered pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
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>
« no previous file with comments | « chrome/test/data/prerender/prerender_plugin_never_load.html ('k') | components/plugins/renderer/loadable_plugin_placeholder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698