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