- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / prerender / prerender_plugin_nacl_enabled.html
1 <html>
2 <!--
3 Make sure prerendered page load NaCl plugins when it's enabled.
4 -->
5 <head>
6 <title>Prerender NaCl Enabled</title>
7 </head>
8 <body>
9
10 <script>
11 var readyToSendResult = false;
12 var pluginLoadStarted = false;
13
14 /**
15  * Sends true if |readyToSendResult| and |pluginLoadStarted| are both true.
16  * Otherwise, does nothing.
17  */
18 function sendResult() {
19   if (!readyToSendResult)
20     return;
21   window.domAutomationController.send(pluginLoadStarted);
22   readyToSendResult = false;
23 }
24
25 function eventListener(event) {
26   var targetElement = event.target;
27   if (event.target.id != 'naclPlugin')
28     return;
29   pluginLoadStarted = true;
30   sendResult();
31 }
32
33 document.body.addEventListener('loadstart', eventListener, true);
34
35 function DidPrerenderPass() {
36   return !pluginLoadStarted;
37 }
38
39 function DidDisplayPass() {
40   return true;
41 }
42
43 /**
44  * It's possible for DidDisplayPass to be called before the loadstart event
45  * happens, since the loadstart event is posted asynchronously when a plugin
46  * loads.  As a result, we need to wait until we've seen both the loadstart
47  * event and been called from the browser process before we can safely send
48  * the real result.
49  */
50 function DidDisplayReallyPass() {
51   readyToSendResult = true;
52   sendResult();
53 }
54 </script>
55
56 <embed id="naclPlugin" type="application/x-nacl" src="dummy.nmf"></embed>
57 </body>
58 </html>