content/base/test/test_file_from_blob.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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>
    14 <pre id="test">
    15 <script>
    17   var b = new Blob(['1234567890']);
    18   ok(b, 'Blob created');
    19   is(b.size, 10, 'Blob has the right size');
    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");
    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");
    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");
    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");
    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, '');
    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, '');
    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, '');
    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');
    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);
    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);
    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);
    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);
   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);
   107 </script>
   108 </pre>
   109 </body>
   110 </html>

mercurial