| Index: ppapi/native_client/tests/ppapi_geturl/ppapi_geturl.html
|
| ===================================================================
|
| --- ppapi/native_client/tests/ppapi_geturl/ppapi_geturl.html (revision 0)
|
| +++ ppapi/native_client/tests/ppapi_geturl/ppapi_geturl.html (revision 0)
|
| @@ -0,0 +1,102 @@
|
| +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
| + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
| +<html>
|
| + <!-- Copyright (c) 2011 Google Inc. All rights reserved. -->
|
| + <head>
|
| + <META HTTP-EQUIV="Pragma" CONTENT="no-cache" />
|
| + <META HTTP-EQUIV="Expires" CONTENT="-1" />
|
| + <script type="text/javascript" src="nacltest.js"></script>
|
| + <script type="text/javascript">
|
| + //<![CDATA[
|
| + // These constants need to match their corresponding values in module.cc.
|
| + var ARGUMENT_SEPARATOR = '|';
|
| + var TRUE_STRING_VALUE = '1';
|
| + var FALSE_STRING_VALUE = '0';
|
| +
|
| + function isMatch(actual, expected) {
|
| + return (0 <= actual.indexOf(expected));
|
| + }
|
| +
|
| + // Convert a string to a boolean value. '1' convertes to |true|,
|
| + // anything else converts to |false|.
|
| + function stringToBool(str_value) {
|
| + return str_value == TRUE_STRING_VALUE;
|
| + }
|
| +
|
| + // Convert a boolean value to the corresponding string value. |true|
|
| + // converts to '1', |false| to '0'.
|
| + function boolToString(bool_value) {
|
| + return bool_value ? TRUE_STRING_VALUE : FALSE_STRING_VALUE;
|
| + }
|
| +
|
| + function setupTests(tester, plugin) {
|
| + function addTest(name, url, as_file, expected_data, expected_success) {
|
| + tester.addAsyncTest(name, function(test) {
|
| + var listener = test.wrap(function(test_response) {
|
| + plugin.removeEventListener('message', listener, false);
|
| +
|
| + var response_args =
|
| + test_response.data.split(ARGUMENT_SEPARATOR);
|
| + test.assertEqual(response_args.length, 4);
|
| +
|
| + // Validate the results.
|
| + var response_url = response_args[0];
|
| + var response_as_file = stringToBool(response_args[1]);
|
| + var response_data = response_args[2];
|
| + var response_success = stringToBool(response_args[3]);
|
| + test.assert(isMatch(response_url, url));
|
| + test.assertEqual(response_as_file, as_file);
|
| + test.log(response_data);
|
| + test.assert(isMatch(response_data, expected_data));
|
| + test.assertEqual(response_success, expected_success);
|
| + test.pass();
|
| + });
|
| + plugin.addEventListener('message', listener, false);
|
| +
|
| + // Make the request.
|
| + var loadUrlMessage = [
|
| + 'loadUrl',
|
| + url,
|
| + boolToString(as_file)].join(ARGUMENT_SEPARATOR);
|
| + plugin.postMessage(loadUrlMessage);
|
| + });
|
| + }
|
| +
|
| + var VALID_URL = 'ppapi_geturl_success.html';
|
| + var CROSSORIGIN_URL = 'http://www.google.com/robots.txt';
|
| + var INVALID_URL = 'ppapi_nonexistent_url.html';
|
| +
|
| + addTest('Valid', VALID_URL, false, 'TEST PASSED', true);
|
| + addTest('Valid_File', VALID_URL, true, 'TEST PASSED', true);
|
| + addTest('CrossOrigin', CROSSORIGIN_URL, false, 'PP_ERROR_NOACCESS',
|
| + false);
|
| + addTest('CrossOrigin_File', CROSSORIGIN_URL, true, 'PP_ERROR_NOACCESS',
|
| + false);
|
| + addTest('Invalid', INVALID_URL, false, '404', false);
|
| + addTest('Invalid_File', INVALID_URL, true, '404', false);
|
| + }
|
| + //]]>
|
| + </script>
|
| +
|
| + <title>PPAPI GetURL Test</title>
|
| + </head>
|
| + <body>
|
| + <h1>PPAPI GetURL Test</h1>
|
| +
|
| + <embed type="application/x-nacl"
|
| + id="nacl"
|
| + name="nacl_module"
|
| + src="ppapi_geturl.nmf"
|
| + width="0" height="0" />
|
| +
|
| + <script type="text/javascript">
|
| + //<![CDATA[
|
| + // TODO(ncbray) allow the test to run in parallel
|
| + var tester = new Tester();
|
| + setupTests(tester, $('nacl'));
|
| + tester.waitFor($('nacl'));
|
| + tester.run();
|
| + //]]>
|
| + </script>
|
| + </body>
|
| +</html>
|
|
|