Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: ppapi/native_client/tests/ppapi_geturl/ppapi_geturl.html

Issue 7740013: Cloning a bunch of stuff from the native_client repository at r6528 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html>
4 <!-- Copyright (c) 2011 Google Inc. All rights reserved. -->
5 <head>
6 <META HTTP-EQUIV="Pragma" CONTENT="no-cache" />
7 <META HTTP-EQUIV="Expires" CONTENT="-1" />
8 <script type="text/javascript" src="nacltest.js"></script>
9 <script type="text/javascript">
10 //<![CDATA[
11 // These constants need to match their corresponding values in module.cc.
12 var ARGUMENT_SEPARATOR = '|';
13 var TRUE_STRING_VALUE = '1';
14 var FALSE_STRING_VALUE = '0';
15
16 function isMatch(actual, expected) {
17 return (0 <= actual.indexOf(expected));
18 }
19
20 // Convert a string to a boolean value. '1' convertes to |true|,
21 // anything else converts to |false|.
22 function stringToBool(str_value) {
23 return str_value == TRUE_STRING_VALUE;
24 }
25
26 // Convert a boolean value to the corresponding string value. |true|
27 // converts to '1', |false| to '0'.
28 function boolToString(bool_value) {
29 return bool_value ? TRUE_STRING_VALUE : FALSE_STRING_VALUE;
30 }
31
32 function setupTests(tester, plugin) {
33 function addTest(name, url, as_file, expected_data, expected_success) {
34 tester.addAsyncTest(name, function(test) {
35 var listener = test.wrap(function(test_response) {
36 plugin.removeEventListener('message', listener, false);
37
38 var response_args =
39 test_response.data.split(ARGUMENT_SEPARATOR);
40 test.assertEqual(response_args.length, 4);
41
42 // Validate the results.
43 var response_url = response_args[0];
44 var response_as_file = stringToBool(response_args[1]);
45 var response_data = response_args[2];
46 var response_success = stringToBool(response_args[3]);
47 test.assert(isMatch(response_url, url));
48 test.assertEqual(response_as_file, as_file);
49 test.log(response_data);
50 test.assert(isMatch(response_data, expected_data));
51 test.assertEqual(response_success, expected_success);
52 test.pass();
53 });
54 plugin.addEventListener('message', listener, false);
55
56 // Make the request.
57 var loadUrlMessage = [
58 'loadUrl',
59 url,
60 boolToString(as_file)].join(ARGUMENT_SEPARATOR);
61 plugin.postMessage(loadUrlMessage);
62 });
63 }
64
65 var VALID_URL = 'ppapi_geturl_success.html';
66 var CROSSORIGIN_URL = 'http://www.google.com/robots.txt';
67 var INVALID_URL = 'ppapi_nonexistent_url.html';
68
69 addTest('Valid', VALID_URL, false, 'TEST PASSED', true);
70 addTest('Valid_File', VALID_URL, true, 'TEST PASSED', true);
71 addTest('CrossOrigin', CROSSORIGIN_URL, false, 'PP_ERROR_NOACCESS',
72 false);
73 addTest('CrossOrigin_File', CROSSORIGIN_URL, true, 'PP_ERROR_NOACCESS',
74 false);
75 addTest('Invalid', INVALID_URL, false, '404', false);
76 addTest('Invalid_File', INVALID_URL, true, '404', false);
77 }
78 //]]>
79 </script>
80
81 <title>PPAPI GetURL Test</title>
82 </head>
83 <body>
84 <h1>PPAPI GetURL Test</h1>
85
86 <embed type="application/x-nacl"
87 id="nacl"
88 name="nacl_module"
89 src="ppapi_geturl.nmf"
90 width="0" height="0" />
91
92 <script type="text/javascript">
93 //<![CDATA[
94 // TODO(ncbray) allow the test to run in parallel
95 var tester = new Tester();
96 setupTests(tester, $('nacl'));
97 tester.waitFor($('nacl'));
98 tester.run();
99 //]]>
100 </script>
101 </body>
102 </html>
OLDNEW
« no previous file with comments | « ppapi/native_client/tests/ppapi_geturl/ppapi_geturl.cc ('k') | ppapi/native_client/tests/ppapi_geturl/ppapi_geturl.nmf » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698