|
1 <!doctype html> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=819900 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for crash caused by unloading and reloading srcdoc iframes</title> |
|
8 <script src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> |
|
10 </head> |
|
11 <body> |
|
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=819900">Mozilla Bug 819900</a> |
|
13 |
|
14 <pre id="test"> |
|
15 <script> |
|
16 |
|
17 var b = new Blob(['1234567890']); |
|
18 ok(b, 'Blob created'); |
|
19 is(b.size, 10, 'Blob has the right size'); |
|
20 |
|
21 var status = false; |
|
22 try { |
|
23 f = new File(b); |
|
24 } catch(e) { |
|
25 status = true; |
|
26 } |
|
27 ok(status, "File throws if the second argument is missing"); |
|
28 |
|
29 status = false; |
|
30 try { |
|
31 f = new File(42, 'foobar.txt'); |
|
32 } catch(e) { |
|
33 status = true; |
|
34 } |
|
35 ok(status, "File throws if the argument is not an array"); |
|
36 |
|
37 status = false; |
|
38 try { |
|
39 f = new File({}, 'foobar.txt'); |
|
40 } catch(e) { |
|
41 status = true; |
|
42 } |
|
43 ok(status, "File throws if the argument is not an array"); |
|
44 |
|
45 status = false; |
|
46 try { |
|
47 f = new File("hello world", 'foobar.txt'); |
|
48 } catch(e) { |
|
49 status = true; |
|
50 } |
|
51 ok(status, "File throws if the argument is not an array"); |
|
52 |
|
53 f = new File(['1234567890'], ''); |
|
54 ok(f, 'File created'); |
|
55 is(f.size, 10, 'File has the right size'); |
|
56 is(f.name, ''); |
|
57 is(f.type, ''); |
|
58 |
|
59 f = new File(['1234567890'], 42); |
|
60 ok(f, 'File created'); |
|
61 is(f.size, 10, 'File has the right size'); |
|
62 is(f.name, '42'); |
|
63 is(f.type, ''); |
|
64 |
|
65 f = new File(['1234567890'], 'text.txt'); |
|
66 ok(f, 'File created'); |
|
67 is(f.size, 10, 'File has the right size'); |
|
68 is(f.name, 'text.txt'); |
|
69 is(f.type, ''); |
|
70 |
|
71 f = new File(['1234567890'], 'text.txt', { type: 'plain/text' }); |
|
72 ok(f, 'File created'); |
|
73 is(f.size, 10, 'File has the right size'); |
|
74 is(f.name, 'text.txt'); |
|
75 is(f.type, 'plain/text'); |
|
76 |
|
77 f = new File([b], 'text.txt'); |
|
78 ok(f, 'File created'); |
|
79 is(f.name, 'text.txt'); |
|
80 is(f.type, ''); |
|
81 is(f.size, b.size); |
|
82 |
|
83 f = new File([b], 'test.txt', { type: 'plain/text' }); |
|
84 ok(f, 'File created'); |
|
85 is(f.name, 'test.txt'); |
|
86 is(f.type, 'plain/text'); |
|
87 is(f.size, b.size); |
|
88 |
|
89 f = new File([b, b], 'test.txt', { type: 'plain/text' }); |
|
90 ok(f, 'File created'); |
|
91 is(f.name, 'test.txt'); |
|
92 is(f.type, 'plain/text'); |
|
93 is(f.size, b.size * 2); |
|
94 |
|
95 var f2 = new File([f, f], 'test.txt', { type: 'plain/text' }); |
|
96 ok(f2, 'File created'); |
|
97 is(f2.name, 'test.txt'); |
|
98 is(f2.type, 'plain/text'); |
|
99 is(f2.size, f.size * 2); |
|
100 |
|
101 var f2 = new File([f, f], 'test.txt', b); |
|
102 ok(f2, 'File created'); |
|
103 is(f2.name, 'test.txt'); |
|
104 is(f2.type, b.type); |
|
105 is(f2.size, f.size * 2); |
|
106 |
|
107 </script> |
|
108 </pre> |
|
109 </body> |
|
110 </html> |
|
111 |