1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 var NaClModulesExpected
= 0;
6 var NaClModulesLoaded
= 0;
8 // Indicate load success.
9 function moduleDidLoad() {
11 if (NaClModulesLoaded
== NaClModulesExpected
)
12 chrome
.test
.sendMessage("nacl_modules_loaded", handleChromeTestMessage
);
15 var handleChromeTestMessage = function (message
) {
16 NaClModules
= document
.querySelectorAll('embed');
17 for (var i
= 0; i
< NaClModules
.length
; i
++) {
18 NaClModules
[i
].postMessage(message
);
22 function handleNaclMessage(message_event
) {
23 console
.log("handleNaclMessage: " + message_event
.data
);
26 function createNaClEmbed() {
27 NaClModulesExpected
++;
29 var listener
= document
.createElement("div");
30 listener
.addEventListener("load", moduleDidLoad
, true);
31 listener
.addEventListener("message", handleNaclMessage
, true);
32 listener
.innerHTML
= '<embed' +
33 ' src="ppapi_tests_extensions_background_keepalive.nmf"' +
34 ' type="application/x-nacl" />';
35 document
.body
.appendChild(listener
);
38 // Create 2 embeds to verify that we can handle more than one.