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

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: merge 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..0c0a3ed5f199b3ac6d21453205a37b0b0ca5b53e
--- /dev/null
+++ b/chrome/test/data/prerender/prerender_plugin_power_saver.html
@@ -0,0 +1,53 @@
+<html>
+<!--
+This test checks the interaction between prerender 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 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['plugin'];
Bernhard Bauer 2015/04/29 09:42:36 Use getElementById? Named properties on the docume
tommycli 2015/04/29 20:25:47 Done.
+ return plugin.postMessage == undefined;
Bernhard Bauer 2015/04/29 09:42:36 Use `===` maybe? `==` can have some weird effects
tommycli 2015/04/29 20:25:47 Done.
+}
+
+// Make sure the plugin briefly exists, then is replaced with a placeholder.
+function AwaitPluginPrerollAndPlaceholder() {
tommycli 2015/04/28 18:43:16 This is the new test 'repros' the old problem and
+ var plugin = window.document['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) {
+ window.domAutomationController.send(false);
+ }
+
+ plugin.addEventListener('message', handleEvent);
+ plugin.postMessage('getPowerSaverStatus');
+}
+</script>
+
+</head>
+<body>
+
+<object name="plugin" type="application/x-ppapi-tests" height='100' width='100'>
+</object>
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698