| <html> | |
| <!-- | |
| Make sure prerendered page load NaCl plugins when it's enabled. | |
| --> | |
| <head> | |
| <title>Prerender NaCl Enabled</title> | |
| </head> | |
| <body> | |
| <script> | |
| var readyToSendResult = false; | |
| var pluginLoadStarted = false; | |
| /** | |
| * Sends true if |readyToSendResult| and |pluginLoadStarted| are both true. | |
| * Otherwise, does nothing. | |
| */ | |
| function sendResult() { | |
| if (!readyToSendResult || !pluginLoadStarted) | |
| return; | |
| window.domAutomationController.send(true); | |
| readyToSendResult = false; | |
| } | |
| function eventListener(event) { | |
| var targetElement = event.target; | |
| if (event.target.id != 'naclPlugin') | |
| return; | |
| pluginLoadStarted = true; | |
| sendResult(); | |
| } | |
| document.body.addEventListener('loadstart', eventListener, true); | |
| function DidPrerenderPass() { | |
| return !pluginLoadStarted; | |
| } | |
| function DidDisplayPass() { | |
| return true; | |
| } | |
| /** | |
| * It's possible for DidDisplayPass to be called before the loadstart event | |
| * happens, since the loadstart event is posted asynchronously when a plugin | |
| * loads. As a result, we need to wait until we've seen both the loadstart | |
| * event and been called from the browser process before we can safely send | |
| * the real result. | |
| */ | |
| function DidDisplayReallyPass() { | |
| readyToSendResult = true; | |
| sendResult(); | |
| } | |
| </script> | |
| <embed id="naclPlugin" type="application/x-nacl" src="dummy.nmf"></embed> | |
| </body> | |
| </html> |