2012-07-31 19:28:23 +00:00
|
|
|
<!--
|
|
|
|
Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
-->
|
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html> <!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=717103
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for the device storage API </title>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="text/javascript" src="devicestorage_common.js"></script>
|
|
|
|
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
2013-01-25 19:05:24 +00:00
|
|
|
|
2012-07-31 19:28:23 +00:00
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
|
|
|
devicestorage_setup();
|
|
|
|
|
2013-01-25 19:05:24 +00:00
|
|
|
function usedSpaceSuccess(e) {
|
|
|
|
ok(e.target.result > 0, "total bytes should exist and be greater than zero");
|
2012-07-31 19:28:23 +00:00
|
|
|
devicestorage_cleanup();
|
|
|
|
}
|
|
|
|
|
2013-01-25 19:05:24 +00:00
|
|
|
function usedSpaceError(e) {
|
|
|
|
ok(false, "usedSpaceError was called");
|
2012-07-31 19:28:23 +00:00
|
|
|
devicestorage_cleanup();
|
|
|
|
}
|
|
|
|
|
2012-09-05 21:30:36 +00:00
|
|
|
var storage = navigator.getDeviceStorage("pictures");
|
2012-07-31 19:28:23 +00:00
|
|
|
|
2012-08-16 23:14:37 +00:00
|
|
|
function addError(e) {
|
|
|
|
ok(false, "addError was called : " + e.target.error.name);
|
2012-07-31 19:28:23 +00:00
|
|
|
devicestorage_cleanup();
|
2012-08-16 23:14:37 +00:00
|
|
|
}
|
2012-07-31 19:28:23 +00:00
|
|
|
|
2012-08-16 23:14:37 +00:00
|
|
|
function addSuccess(e) {
|
2013-01-25 19:05:24 +00:00
|
|
|
request = storage.usedSpace();
|
2012-08-16 23:14:37 +00:00
|
|
|
ok(request, "Should have a non-null request");
|
2012-07-31 19:28:23 +00:00
|
|
|
|
2013-01-25 19:05:24 +00:00
|
|
|
request.onsuccess = usedSpaceSuccess;
|
|
|
|
request.onerror = usedSpaceError;
|
2012-07-31 19:28:23 +00:00
|
|
|
}
|
|
|
|
|
2013-07-12 07:18:28 +00:00
|
|
|
var prefix = "devicestorage/" + randomFilename(12);
|
|
|
|
request = storage.addNamed(createRandomBlob('image/png'), prefix + "/a/b.png");
|
2012-08-16 23:14:37 +00:00
|
|
|
request.onsuccess = addSuccess;
|
|
|
|
request.onerror = addError;
|
|
|
|
|
2012-07-31 19:28:23 +00:00
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|