OLD | NEW |
| (Empty) |
1 // Runs a series of tests related to importing scripts on a worklet. | |
2 // | |
3 // Usage: | |
4 // runImportTests(workletType); | |
5 function runImportTests(worklet) { | |
6 promise_test(function() { | |
7 | |
8 return worklet.import('resources/empty-worklet-script.js').then(function
(undefined_arg) { | |
9 assert_equals(undefined_arg, undefined, 'Promise should resolve with
no arguments.'); | |
10 }).catch(function(error) { | |
11 assert_unreached('unexpected rejection: ' + error); | |
12 }); | |
13 | |
14 }, 'Importing a script resolves the given promise.'); | |
15 | |
16 promise_test(function() { | |
17 | |
18 return worklet.import('resources/throwing-worklet-script.js').then(funct
ion(undefined_arg) { | |
19 assert_equals(undefined_arg, undefined, 'Promise should resolve with
no arguments.'); | |
20 }).catch(function(error) { | |
21 assert_unreached('unexpected rejection: ' + error); | |
22 }); | |
23 | |
24 }, 'Importing a script which throws should still resolve the given promise.'
); | |
25 | |
26 promise_test(function() { | |
27 | |
28 return worklet.import('non-existant-worklet-script.js').then(function()
{ | |
29 assert_unreached('import should fail.'); | |
30 }).catch(function(error) { | |
31 assert_equals(error.name, 'NetworkError', 'error should be a Network
Error.'); | |
32 }); | |
33 | |
34 }, 'Importing a non-existant script rejects the given promise with a Network
Error.'); | |
35 | |
36 promise_test(function() { | |
37 | |
38 return worklet.import('http://invalid:123$').then(function() { | |
39 assert_unreached('import should fail.'); | |
40 }).catch(function(error) { | |
41 assert_equals(error.name, 'SyntaxError', 'error should be a SyntaxEr
ror.'); | |
42 }); | |
43 | |
44 }, 'Attempting to resolve an invalid URL should reject the given promise wit
h a SyntaxError.'); | |
45 } | |
OLD | NEW |