Add ncval-stubout tool
[nativeclient.git] / tests / mm_init / mm_init.html
blob12d40d7679317e5ec5a67d4a05c89151c829c6c8
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Native Client MMInit</title>
5 <script type="text/javascript">
6 var naclModule;
7 var pluginElement;
8 var upcallButtonElement;
9 var shutdownButtonElement;
10 // SRPC's embeds can launch an arbitrary number of Native Client modules.
11 // Each module is loaded from the web and started in sel_ldr by a call
12 // to the loadURL method on a plugin instance. DownloadCallbacks are
13 // used to report success or failure from module loads.
14 var DownloadCallback = function() {
15 // The onload method is invoked after successful download of a module
16 // and its starting in sel_ldr. It is passed a handle to the module
17 // that can then have services invoked on it.
18 this.onload = function(module) {
19 // We save the returned handle to the module in a global variable.
20 // This global variable is used to invoke rpcs in helloworld.
21 naclModule = module;
22 // Allow the user to push the button (it was disabled by default).
23 upcallButtonElement.disabled = null;
24 shutdownButtonElement.disabled = null;
26 this.onfail = function(string) {
27 // If the load or startup of the sel_ldr instance fails, this method
28 // is invoked with an error string.
29 window.alert('Error: ' + string);
32 // Init records a couple of HTML elements used for running the tests and
33 // requests the download of the Native Client module.
34 var Init = function() {
35 pluginElement = document.getElementById('pluginobj');
36 upcallButtonElement = document.getElementById('upcallbuttonobj');
37 shutdownButtonElement = document.getElementById('shutdownbuttonobj');
38 pluginElement.loadURL('mm_init', new DownloadCallback);
40 // do_upcall is invoked when its button is pressed.
41 function do_upcall() {
42 try {
43 alert(naclModule.do_upcall());
44 } catch(e) {
45 alert(e);
48 // shutdown is invoked when its button is pressed.
49 function shutdown() {
50 try {
51 alert(naclModule.shutdown());
52 } catch(e) {
53 alert(e);
56 </script>
57 </head>
58 <body onload="Init()">
60 <h1>Native Client Multimedia Example </h1>
61 <p>
63 <button onclick='do_upcall()' id='upcallbuttonobj' disabled='true'>
64 Call do_upcall()
65 </button>
66 <button onclick='shutdown()' id='shutdownbuttonobj' disabled='true'>
67 Call shutdown()
68 </button>
69 <embed id="pluginobj"
70 type="application/x-nacl-srpc" width=100 height=100 />
71 </p>
73 <p>All results from this test are given in the command shell that invoked
74 the browser.<p>
76 </body>
77 </html>