OLD | NEW |
1 <!DOCTYPE html> | 1 // Runs a series of tests related to importing scripts on a worklet. |
2 <html> | 2 // |
3 <head> | 3 // Usage: |
4 <script src="../resources/testharness.js"></script> | 4 // runImportTests(workletType); |
5 <script src="../resources/testharnessreport.js"></script> | 5 function runImportTests(worklet, opt_path) { |
6 </head> | 6 const path = opt_path || ''; |
7 <body> | 7 |
8 <script> | |
9 promise_test(function() { | 8 promise_test(function() { |
10 | 9 return worklet.import(path + 'resources/empty-worklet-script.js').then(f
unction(undefined_arg) { |
11 return paintWorklet.import('resources/empty-worklet-script.js').then(fun
ction(undefined_arg) { | |
12 assert_equals(undefined_arg, undefined, 'Promise should resolve with
no arguments.'); | 10 assert_equals(undefined_arg, undefined, 'Promise should resolve with
no arguments.'); |
13 }).catch(function(error) { | 11 }).catch(function(error) { |
14 assert_unreached('unexpected rejection: ' + error); | 12 assert_unreached('unexpected rejection: ' + error); |
15 }); | 13 }); |
16 | 14 |
17 }, 'Importing a script resolves the given promise.'); | 15 }, 'Importing a script resolves the given promise.'); |
18 | 16 |
19 promise_test(function() { | 17 promise_test(function() { |
20 | 18 |
21 return paintWorklet.import('resources/throwing-worklet-script.js').then(
function(undefined_arg) { | 19 return worklet.import(path + 'resources/throwing-worklet-script.js').the
n(function(undefined_arg) { |
22 assert_equals(undefined_arg, undefined, 'Promise should resolve with
no arguments.'); | 20 assert_equals(undefined_arg, undefined, 'Promise should resolve with
no arguments.'); |
23 }).catch(function(error) { | 21 }).catch(function(error) { |
24 assert_unreached('unexpected rejection: ' + error); | 22 assert_unreached('unexpected rejection: ' + error); |
25 }); | 23 }); |
26 | 24 |
27 }, 'Importing a script which throws should still resolve the given promise.'
); | 25 }, 'Importing a script which throws should still resolve the given promise.'
); |
28 | 26 |
29 promise_test(function() { | 27 promise_test(function() { |
30 | 28 |
31 return paintWorklet.import('non-existant-worklet-script.js').then(functi
on() { | 29 return worklet.import(path + 'non-existant-worklet-script.js').then(func
tion() { |
32 assert_unreached('import should fail.'); | 30 assert_unreached('import should fail.'); |
33 }).catch(function(error) { | 31 }).catch(function(error) { |
34 assert_equals(error.name, 'NetworkError', 'error should be a Network
Error.'); | 32 assert_equals(error.name, 'NetworkError', 'error should be a Network
Error.'); |
35 }); | 33 }); |
36 | 34 |
37 }, 'Importing a non-existant script rejects the given promise with a Network
Error.'); | 35 }, 'Importing a non-existant script rejects the given promise with a Network
Error.'); |
38 | 36 |
39 promise_test(function() { | 37 promise_test(function() { |
40 | 38 |
41 return paintWorklet.import('http://invalid:123$').then(function() { | 39 return worklet.import('http://invalid:123$').then(function() { |
42 assert_unreached('import should fail.'); | 40 assert_unreached('import should fail.'); |
43 }).catch(function(error) { | 41 }).catch(function(error) { |
44 assert_equals(error.name, 'SyntaxError', 'error should be a SyntaxEr
ror.'); | 42 assert_equals(error.name, 'SyntaxError', 'error should be a SyntaxEr
ror.'); |
45 }); | 43 }); |
46 | 44 |
47 }, 'Attempting to resolve an invalid URL should reject the given promise wit
h a SyntaxError.'); | 45 }, 'Attempting to resolve an invalid URL should reject the given promise wit
h a SyntaxError.'); |
48 | 46 } |
49 </script> | |
50 </body> | |
51 </html> | |
OLD | NEW |