2012-07-31 23:28:23 +04: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 23:05:24 +04:00
|
|
|
|
2012-07-31 23:28:23 +04:00
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
2015-11-20 20:18:22 +03:00
|
|
|
devicestorage_setup(function () {
|
2012-07-31 23:28:23 +04:00
|
|
|
|
2013-01-25 23:05:24 +04:00
|
|
|
function usedSpaceSuccess(e) {
|
|
|
|
ok(e.target.result > 0, "total bytes should exist and be greater than zero");
|
2015-11-20 20:18:22 +03:00
|
|
|
SimpleTest.finish();
|
2012-07-31 23:28:23 +04:00
|
|
|
}
|
|
|
|
|
2013-01-25 23:05:24 +04:00
|
|
|
function usedSpaceError(e) {
|
|
|
|
ok(false, "usedSpaceError was called");
|
2015-11-20 20:18:22 +03:00
|
|
|
SimpleTest.finish();
|
2012-07-31 23:28:23 +04:00
|
|
|
}
|
|
|
|
|
2012-09-06 01:30:36 +04:00
|
|
|
var storage = navigator.getDeviceStorage("pictures");
|
2012-07-31 23:28:23 +04:00
|
|
|
|
2012-08-17 03:14:37 +04:00
|
|
|
function addError(e) {
|
|
|
|
ok(false, "addError was called : " + e.target.error.name);
|
2015-11-20 20:18:22 +03:00
|
|
|
SimpleTest.finish();
|
2012-08-17 03:14:37 +04:00
|
|
|
}
|
2012-07-31 23:28:23 +04:00
|
|
|
|
2012-08-17 03:14:37 +04:00
|
|
|
function addSuccess(e) {
|
2013-01-25 23:05:24 +04:00
|
|
|
request = storage.usedSpace();
|
2012-08-17 03:14:37 +04:00
|
|
|
ok(request, "Should have a non-null request");
|
2012-07-31 23:28:23 +04:00
|
|
|
|
2013-01-25 23:05:24 +04:00
|
|
|
request.onsuccess = usedSpaceSuccess;
|
|
|
|
request.onerror = usedSpaceError;
|
2012-07-31 23:28:23 +04:00
|
|
|
}
|
|
|
|
|
2013-07-12 11:18:28 +04:00
|
|
|
var prefix = "devicestorage/" + randomFilename(12);
|
|
|
|
request = storage.addNamed(createRandomBlob('image/png'), prefix + "/a/b.png");
|
2012-08-17 03:14:37 +04:00
|
|
|
request.onsuccess = addSuccess;
|
|
|
|
request.onerror = addError;
|
|
|
|
|
2015-11-20 20:18:22 +03:00
|
|
|
});
|
|
|
|
|
2012-07-31 23:28:23 +04:00
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|