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) { |
6 </head> | |
7 <body> | |
8 <script> | |
9 promise_test(function() { | 6 promise_test(function() { |
10 | 7 |
11 return paintWorklet.import('resources/empty-worklet-script.js').then(fun
ction(undefined_arg) { | 8 return worklet.import('resources/empty-worklet-script.js').then(function
(undefined_arg) { |
12 assert_equals(undefined_arg, undefined, 'Promise should resolve with
no arguments.'); | 9 assert_equals(undefined_arg, undefined, 'Promise should resolve with
no arguments.'); |
13 }).catch(function(error) { | 10 }).catch(function(error) { |
14 assert_unreached('unexpected rejection: ' + error); | 11 assert_unreached('unexpected rejection: ' + error); |
15 }); | 12 }); |
16 | 13 |
17 }, 'Importing a script resolves the given promise.'); | 14 }, 'Importing a script resolves the given promise.'); |
18 | 15 |
19 promise_test(function() { | 16 promise_test(function() { |
20 | 17 |
21 return paintWorklet.import('resources/throwing-worklet-script.js').then(
function(undefined_arg) { | 18 return worklet.import('resources/throwing-worklet-script.js').then(funct
ion(undefined_arg) { |
22 assert_equals(undefined_arg, undefined, 'Promise should resolve with
no arguments.'); | 19 assert_equals(undefined_arg, undefined, 'Promise should resolve with
no arguments.'); |
23 }).catch(function(error) { | 20 }).catch(function(error) { |
24 assert_unreached('unexpected rejection: ' + error); | 21 assert_unreached('unexpected rejection: ' + error); |
25 }); | 22 }); |
26 | 23 |
27 }, 'Importing a script which throws should still resolve the given promise.'
); | 24 }, 'Importing a script which throws should still resolve the given promise.'
); |
28 | 25 |
29 promise_test(function() { | 26 promise_test(function() { |
30 | 27 |
31 return paintWorklet.import('non-existant-worklet-script.js').then(functi
on() { | 28 return worklet.import('non-existant-worklet-script.js').then(function()
{ |
32 assert_unreached('import should fail.'); | 29 assert_unreached('import should fail.'); |
33 }).catch(function(error) { | 30 }).catch(function(error) { |
34 assert_equals(error.name, 'NetworkError', 'error should be a Network
Error.'); | 31 assert_equals(error.name, 'NetworkError', 'error should be a Network
Error.'); |
35 }); | 32 }); |
36 | 33 |
37 }, 'Importing a non-existant script rejects the given promise with a Network
Error.'); | 34 }, 'Importing a non-existant script rejects the given promise with a Network
Error.'); |
38 | 35 |
39 promise_test(function() { | 36 promise_test(function() { |
40 | 37 |
41 return paintWorklet.import('http://invalid:123$').then(function() { | 38 return worklet.import('http://invalid:123$').then(function() { |
42 assert_unreached('import should fail.'); | 39 assert_unreached('import should fail.'); |
43 }).catch(function(error) { | 40 }).catch(function(error) { |
44 assert_equals(error.name, 'SyntaxError', 'error should be a SyntaxEr
ror.'); | 41 assert_equals(error.name, 'SyntaxError', 'error should be a SyntaxEr
ror.'); |
45 }); | 42 }); |
46 | 43 |
47 }, 'Attempting to resolve an invalid URL should reject the given promise wit
h a SyntaxError.'); | 44 }, 'Attempting to resolve an invalid URL should reject the given promise wit
h a SyntaxError.'); |
48 | 45 } |
49 </script> | |
50 </body> | |
51 </html> | |
OLD | NEW |