@@ -5,13 +5,91 @@ test(() => {
5
5
} , `fetchLater() cannot be called without request.` ) ;
6
6
7
7
test ( ( ) => {
8
- assert_throws_js ( TypeError , ( ) => fetchLater ( 'http://www.google.com' ) ) ;
8
+ const result = fetchLater ( '/' ) ;
9
+ assert_false ( result . activated , `result.activated should be false for '/'` ) ;
10
+ } , `fetchLater() with same-origin (https) URL does not throw.` ) ;
11
+
12
+ test ( ( ) => {
13
+ const url = 'http://localhost' ;
14
+ const result = fetchLater ( url ) ;
15
+ assert_false ( result . activated , `result.activated should be false for ${ url } ` ) ;
16
+ } , `fetchLater() with http://localhost URL does not throw.` ) ;
17
+
18
+ test ( ( ) => {
19
+ const url = 'https://localhost' ;
20
+ const result = fetchLater ( url ) ;
21
+ assert_false ( result . activated , `result.activated should be false for ${ url } ` ) ;
22
+ } , `fetchLater() with https://localhost URL does not throw.` ) ;
23
+
24
+ test ( ( ) => {
25
+ const url = 'http://127.0.0.1' ;
26
+ const result = fetchLater ( url ) ;
27
+ assert_false ( result . activated , `result.activated should be false for ${ url } ` ) ;
28
+ } , `fetchLater() with http://127.0.0.1 URL does not throw.` ) ;
29
+
30
+ test ( ( ) => {
31
+ const url = 'https://127.0.0.1' ;
32
+ const result = fetchLater ( url ) ;
33
+ assert_false ( result . activated , `result.activated should be false for ${ url } ` ) ;
34
+ } , `fetchLater() with https://127.0.0.1 URL does not throw.` ) ;
35
+
36
+ test ( ( ) => {
37
+ const url = 'http://[::1]' ;
38
+ const result = fetchLater ( url ) ;
39
+ assert_false ( result . activated , `result.activated should be false for ${ url } ` ) ;
40
+ } , `fetchLater() with http://[::1] URL does not throw.` ) ;
41
+
42
+ test ( ( ) => {
43
+ const url = 'https://[::1]' ;
44
+ const result = fetchLater ( url ) ;
45
+ assert_false ( result . activated , `result.activated should be false for ${ url } ` ) ;
46
+ } , `fetchLater() with https://[::1] URL does not throw.` ) ;
47
+
48
+ test ( ( ) => {
49
+ const url = 'https://example.com' ;
50
+ const result = fetchLater ( url ) ;
51
+ assert_false ( result . activated , `result.activated should be false for ${ url } ` ) ;
52
+ } , `fetchLater() with https://example.com URL does not throw.` ) ;
53
+
54
+ test ( ( ) => {
55
+ const httpUrl = 'http://example.com' ;
56
+ assert_throws_dom (
57
+ 'SecurityError' , ( ) => fetchLater ( httpUrl ) ,
58
+ `should throw SecurityError for insecure http url ${ httpUrl } ` ) ;
59
+ } , `fetchLater() throws SecurityError on non-trustworthy http URL.` ) ;
60
+
61
+ test ( ( ) => {
9
62
assert_throws_js ( TypeError , ( ) => fetchLater ( 'file://tmp' ) ) ;
63
+ } , `fetchLater() throws TypeError on file:// scheme.` ) ;
64
+
65
+ test ( ( ) => {
66
+ assert_throws_js ( TypeError , ( ) => fetchLater ( 'ftp://example.com' ) ) ;
67
+ } , `fetchLater() throws TypeError on ftp:// scheme.` ) ;
68
+
69
+ test ( ( ) => {
10
70
assert_throws_js ( TypeError , ( ) => fetchLater ( 'ssh://example.com' ) ) ;
71
+ } , `fetchLater() throws TypeError on ssh:// scheme.` ) ;
72
+
73
+ test ( ( ) => {
11
74
assert_throws_js ( TypeError , ( ) => fetchLater ( 'wss://example.com' ) ) ;
75
+ } , `fetchLater() throws TypeError on wss:// scheme.` ) ;
76
+
77
+ test ( ( ) => {
12
78
assert_throws_js ( TypeError , ( ) => fetchLater ( 'about:blank' ) ) ;
79
+ } , `fetchLater() throws TypeError on about: scheme.` ) ;
80
+
81
+ test ( ( ) => {
13
82
assert_throws_js ( TypeError , ( ) => fetchLater ( `javascript:alert('');` ) ) ;
14
- } , `fetchLater() throws TypeError on non-HTTPS URL.` ) ;
83
+ } , `fetchLater() throws TypeError on javascript: scheme.` ) ;
84
+
85
+ test ( ( ) => {
86
+ assert_throws_js ( TypeError , ( ) => fetchLater ( 'data:text/plain,Hello' ) ) ;
87
+ } , `fetchLater() throws TypeError on data: scheme.` ) ;
88
+
89
+ test ( ( ) => {
90
+ assert_throws_js (
91
+ TypeError , ( ) => fetchLater ( 'blob:https://example.com/some-uuid' ) ) ;
92
+ } , `fetchLater() throws TypeError on blob: scheme.` ) ;
15
93
16
94
test ( ( ) => {
17
95
assert_throws_js (
0 commit comments