| <html> | |
| <!-- | |
| This test checks to make sure plugins aren't loaded when a page is prerendered, | |
| but are loaded once the page is displayed. | |
| 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']; | |
| return plugin.postMessage == undefined; | |
| } | |
| // DidDisplayPass requires a synchronously returned result, but we can't | |
| // determine if the delayed plugin loaded correctly synchronously. | |
| function DidDisplayPass() { | |
| return true; | |
| } | |
| // Make sure plugin loads once the page is displayed. | |
| function DidPluginLoad() { | |
| var plugin = window.document['plugin']; | |
| // Listen for either the initial status ping, or the requested status ping. | |
| plugin.addEventListener('message', function handleEvent(event) { | |
| if (event.data.source === 'getPowerSaverStatusResponse' || | |
| event.data.source === 'initial') { | |
| plugin.removeEventListener('message', handleEvent); | |
| window.domAutomationController.send(true); | |
| } | |
| }); | |
| // If the plugin has already loaded, we have missed the initial status ping, | |
| // so we specifically request one. | |
| if (plugin.postMessage) | |
| plugin.postMessage('getPowerSaverStatus'); | |
| // Plugins don't have a time limit for loading, so failure is via timeout. | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <!-- Specifically define the data attribute to be same-origin. Otherwise, | |
| Plugin Power Saver will further defer the loading of the plugin. --> | |
| <object name='plugin' data='fake.swf' type='application/x-shockwave-flash'> | |
| </object> | |
| </body> | |
| </html> |