dom/devicestorage/test/test_add.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/devicestorage/test/test_add.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +<!--
     1.5 +  Any copyright is dedicated to the Public Domain.
     1.6 +  http://creativecommons.org/publicdomain/zero/1.0/
     1.7 +-->
     1.8 +<!DOCTYPE HTML>
     1.9 +<html>
    1.10 +<!--
    1.11 +https://bugzilla.mozilla.org/show_bug.cgi?id=786922
    1.12 +-->
    1.13 +<head>
    1.14 +  <title>Test for basic sanity of the device storage API </title>
    1.15 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.16 +  <script type="text/javascript" src="devicestorage_common.js"></script>
    1.17 +
    1.18 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.19 +</head>
    1.20 +<body>
    1.21 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=786922">Mozilla Bug 786922</a>
    1.22 +<p id="display"></p>
    1.23 +<div id="content" style="display: none">
    1.24 +  
    1.25 +</div>
    1.26 +<pre id="test">
    1.27 +<script class="testbody" type="text/javascript">
    1.28 +
    1.29 +
    1.30 +devicestorage_setup();
    1.31 +
    1.32 +function add(storage, mime) {
    1.33 +  dump("adding: " + mime + "\n");
    1.34 +  return navigator.getDeviceStorage(storage).add(createRandomBlob(mime));
    1.35 +}
    1.36 +
    1.37 +var tests = [
    1.38 +  function () { return add("pictures", "image/png")},
    1.39 +  function () { return add("videos",   "video/webm")},
    1.40 +  function () { return add("music",    "audio/wav")},
    1.41 +  function () { return add("sdcard",   "maple/cookies")},
    1.42 +];
    1.43 +
    1.44 +function fail(e) {
    1.45 +  ok(false, "onerror was called");
    1.46 +  devicestorage_cleanup();
    1.47 +}
    1.48 +
    1.49 +function next(e) {
    1.50 +
    1.51 +  if (e != undefined)
    1.52 +    ok(true, "addError was called");
    1.53 +  
    1.54 +  var f = tests.pop();
    1.55 +
    1.56 +  if (f == undefined) {
    1.57 +    devicestorage_cleanup();
    1.58 +    return;
    1.59 +  }
    1.60 +
    1.61 +  request = f();
    1.62 +  request.onsuccess = next;
    1.63 +  request.onerror = fail;
    1.64 +}
    1.65 +
    1.66 +next();
    1.67 +
    1.68 +</script>
    1.69 +</pre>
    1.70 +</body>
    1.71 +</html>
    1.72 +

mercurial