Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
1 <!--
2 Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/
4 -->
5 <!DOCTYPE HTML>
6 <html> <!--
7 https://bugzilla.mozilla.org/show_bug.cgi?id=717103
8 -->
9 <head>
10 <title>Test for the device storage API </title>
11 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
12 <script type="text/javascript" src="devicestorage_common.js"></script>
14 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
15 </head>
16 <body>
17 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
18 <p id="display"></p>
19 <div id="content" style="display: none">
21 </div>
22 <pre id="test">
23 <script class="testbody" type="text/javascript">
25 devicestorage_setup();
28 var freeBytes = -1;
29 var stats = 0;
31 function stat(s, file_list_length) {
32 if (freeBytes == -1) {
33 freeBytes = s.target.result.freeBytes;
34 }
36 ok(freeBytes == s.target.result.freeBytes, "Free bytes should be the same");
37 ok(file_list_length * 1024 == s.target.result.totalBytes, "space taken up by files should match")
39 stats = stats + 1;
41 if (stats == 2) {
42 devicestorage_cleanup();
43 }
44 }
46 function addSuccess(e) {
47 added = added - 1;
49 if (added == 0) {
50 request = pictures.stat();
51 request.onsuccess = function(s) {stat(s, picture_files.length)};
53 request = videos.stat();
54 request.onsuccess = function(s) {stat(s, video_files.length)};
56 request = music.stat();
57 request.onsuccess = function(s) {stat(s, music_files.length)};
58 }
59 }
61 function addError(e) {
62 ok(false, "addError was called : " + e.target.error.name);
63 devicestorage_cleanup();
64 }
66 ok(true, "hi");
68 var pictures = navigator.getDeviceStorage("pictures");
69 var picture_files = [ "a.png", "b.png", "c.png", "d.png", "e.png" ];
71 var videos = navigator.getDeviceStorage("videos");
72 var video_files = [ "a.ogv", "b.ogv" ];
74 var music = navigator.getDeviceStorage("music");
75 var music_files = [ "a.mp3", "b.mp3", "c.mp3" ];
77 var added = picture_files.length + video_files.length + music_files.length;
79 for (var i=0; i < picture_files.length; i++) {
80 request = pictures.addNamed(createRandomBlob('image/png'), picture_files[i]);
81 request.onsuccess = addSuccess;
82 request.onerror = addError;
83 }
85 for (var i=0; i < video_files.length; i++) {
86 request = videos.addNamed(createRandomBlob('video/ogv'), video_files[i]);
87 request.onsuccess = addSuccess;
88 request.onerror = addError;
89 }
91 for (var i=0; i < music_files.length; i++) {
92 request = music.addNamed(createRandomBlob('audio/mp3'), music_files[i]);
93 request.onsuccess = addSuccess;
94 request.onerror = addError;
95 }
97 </script>
98 </pre>
99 </body>
100 </html>