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

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..001bd022e3913ddb9756a87e43f092e7369c06b7
--- /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) {
+ plugin.removeEventListener('message', handleEvent);
+ window.domAutomationController.send(plugin.postMessage === undefined);
+ }
+ }
+
+ // The plugin should (briefly) exist for the preroll phase.
+ if (plugin.postMessage == undefined) {
Bernhard Bauer 2015/04/30 08:09:36 ===
tommycli 2015/04/30 21:54:31 Done.
+ window.domAutomationController.send(false);
+ return;
+ }
+
+ plugin.addEventListener('message', handleEvent);
+ plugin.postMessage('getPowerSaverStatus');
+}
+</script>
+
+</head>
+<body>
+
+<object id="plugin" type="application/x-ppapi-tests" height='100' width='100'>
+</object>
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698