OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <!-- Copyright (c) 2010 The Native Client Authors. All rights reserved. | |
4 Use of this source code is governed by a BSD-style license that can be | |
5 found in the LICENSE file. --> | |
6 <head> | |
7 <title>PPAPI Runtime Feature Test</title> | |
8 <meta HTTP-EQUIV="Pragma" CONTENT="no-cache" /> | |
9 <meta HTTP-EQUIV="Expires" CONTENT="-1" /> | |
10 <script type="text/javascript" src="nacltest.js"></script> | |
11 </head> | |
12 <body> | |
13 | |
14 <script type="text/javascript"> | |
15 //<![CDATA[ | |
16 | |
17 var kSampleInt = 1; | |
18 var kSampleString = 'hello, world'; | |
19 var kSampleObject = new Array(10); | |
20 | |
21 | |
22 function EnqueueTests(tester, naclModule, suffix) { | |
23 // Test access to NaCl ppruntime objects from the browser. | |
24 // Read a property that is not set. | |
25 tester.addTest('browser_nacl_read_notset' + suffix, function() { | |
26 assertEqual(naclModule.propertyUnset, undefined); | |
27 }); | |
28 | |
29 // Read a property that is set. | |
30 tester.addTest('browser_nacl_read_set' + suffix, function() { | |
31 assertEqual(naclModule.propNull, null); | |
32 }); | |
33 | |
34 // Write and read back an integer property. | |
35 tester.addTest('browser_nacl_int_property' + suffix, function() { | |
36 naclModule.propInt32 = 7; | |
37 assertEqual(naclModule.propInt32, 7); | |
38 naclModule.propInt32 = 11; | |
39 assertEqual(naclModule.propInt32, 11); | |
40 }); | |
41 | |
42 // Read back the property. | |
43 tester.addTest('browser_nacl_string_property' + suffix, function() { | |
44 naclModule.propString = 'hello'; | |
45 assertEqual(naclModule.propString, 'hello'); | |
46 naclModule.propString = 'world'; | |
47 assertEqual(naclModule.propString, 'world'); | |
48 }); | |
49 | |
50 // Broken, throws an exception. | |
51 // TODO(ncbray) fix or remove. | |
52 /* | |
53 tester.addTest('browser_nacl_object_double_deref' + suffix, function() { | |
54 naclModule.propObject = kSampleObject; | |
55 var temp1 = naclModule.propObject; | |
56 var temp2 = naclModule.propObject; | |
57 // The second deref has throw an exception, in the past. | |
58 }); | |
59 */ | |
60 | |
61 // Broken, corrupted object returned. | |
62 // TODO(ncbray) fix or remove. | |
63 // http://code.google.com/p/nativeclient/issues/detail?id=1367 | |
64 /* | |
65 // Write and read back an object property. | |
66 tester.addTest('browser_nacl_object_write' + suffix, function() { | |
67 naclModule.propObject = kSampleObject; | |
68 assertEqual(naclModule.propObject, kSampleObject); | |
69 }); | |
70 */ | |
71 | |
72 // Argument passing and return. | |
73 tester.addTest('browser_nacl_int_argret' + suffix, function() { | |
74 assertEqual(naclModule.methodInt32(13), 13); | |
75 }); | |
76 | |
77 tester.addTest('browser_nacl_string_argret' + suffix, function() { | |
78 assertEqual(naclModule.methodString('bogus'), 'bogus'); | |
79 }); | |
80 | |
81 // Broken, corrupted object returned. | |
82 // TODO(ncbray) fix or remove. | |
83 // http://code.google.com/p/nativeclient/issues/detail?id=1367 | |
84 /* | |
85 tester.addTest('browser_nacl_object_argret' + suffix, function() { | |
86 assertEqual(naclModule.methodObject(kSampleObject), kSampleObject); | |
87 }); | |
88 */ | |
89 | |
90 // Multi-argument passing and return. | |
91 tester.addTest('browser_nacl_int_2_argret' + suffix, function() { | |
92 assertEqual(naclModule.methodInt32With2Args(kSampleInt, kSampleInt), | |
93 kSampleInt); | |
94 }); | |
95 | |
96 tester.addTest('browser_nacl_string_2_argret' + suffix, function() { | |
97 assertEqual(naclModule.methodStringWith2Args(kSampleString, kSampleString), | |
98 kSampleString); | |
99 }); | |
100 | |
101 // Broken, corrupted object returned. | |
102 // TODO(ncbray) fix or remove. | |
103 // http://code.google.com/p/nativeclient/issues/detail?id=1367 | |
104 /* | |
105 tester.addTest('browser_nacl_object_2_argret' + suffix, function() { | |
106 assertEqual(naclModule.methodObjectWith2Args(kSampleObject, kSampleObject), | |
107 kSampleObject); | |
108 }); | |
109 */ | |
110 | |
111 // Call a method with 0 args (tests issue: | |
112 // http://code.google.com/p/nativeclient/issues/detail?id=891) | |
113 tester.addTest('browser_nacl_0_argret' + suffix, function() { | |
114 assertEqual(naclModule.helloWorld(), 'hello, world'); | |
115 }); | |
116 | |
117 tester.addTest('nacl_browser_window_location_prop', function() { | |
118 assertEqual(naclModule.windowLocation(window), true); | |
119 }); | |
120 } | |
121 | |
122 | |
123 //]]> | |
124 </script> | |
125 | |
126 <embed id="basic_object" | |
127 name="naclModule" | |
128 width=0 height=0 | |
129 src="basic_object.nmf" | |
130 type="application/x-nacl" /> | |
131 </body> | |
132 | |
133 <embed id="user_main" | |
134 name="naclModule" | |
135 width=0 height=0 | |
136 src="user_main.nmf" | |
137 type="application/x-nacl" /> | |
138 </body> | |
139 | |
140 <script type="text/javascript"> | |
141 //<![CDATA[ | |
142 var tester = new Tester(); | |
143 EnqueueTests(tester, $('basic_object'), ''); | |
144 // Same interface but with a user-supplied main() entry point. | |
145 EnqueueTests(tester, $('user_main'), '_user'); | |
146 tester.waitFor($('basic_object'), $('user_main')); | |
147 tester.run(); | |
148 //]]> | |
149 </script> | |
150 </html> | |
OLD | NEW |