dom/devicestorage/test/test_dotdot.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/devicestorage/test/test_dotdot.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     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 +https://bugzilla.mozilla.org/show_bug.cgi?id=717103
    1.11 +-->
    1.12 +<head>
    1.13 +  <title>Test for the device storage API </title>
    1.14 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.15 +  <script type="text/javascript" src="devicestorage_common.js"></script>
    1.16 +
    1.17 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.18 +</head>
    1.19 +<body>
    1.20 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
    1.21 +<p id="display"></p>
    1.22 +<div id="content" style="display: none">
    1.23 +  
    1.24 +</div>
    1.25 +<pre id="test">
    1.26 +<script class="testbody" type="text/javascript">
    1.27 +
    1.28 +devicestorage_setup();
    1.29 +
    1.30 +function testingStorage() {
    1.31 +  return navigator.getDeviceStorage("pictures");
    1.32 +}
    1.33 +
    1.34 +var tests = [
    1.35 +  function () { return testingStorage().addNamed(createRandomBlob('image/png'), gFileName); },
    1.36 +  function () { return testingStorage().delete(gFileName); },
    1.37 +  function () { return testingStorage().get(gFileName); },
    1.38 +  function () { var r = testingStorage().enumerate("../"); return r; }
    1.39 +];
    1.40 +
    1.41 +var gFileName = "../owned.png";
    1.42 +
    1.43 +function fail(e) {
    1.44 +  ok(false, "addSuccess was called");
    1.45 +  dump(request);
    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 +    ok(e.target.error.name == "SecurityError", "Error must be SecurityError");
    1.54 +  }
    1.55 +
    1.56 +  var f = tests.pop();
    1.57 +
    1.58 +  if (f == undefined) {
    1.59 +    devicestorage_cleanup();
    1.60 +    return;
    1.61 +  }
    1.62 +
    1.63 +  request = f();
    1.64 +  request.onsuccess = fail;
    1.65 +  request.onerror = next;
    1.66 +}
    1.67 +
    1.68 +next();
    1.69 +
    1.70 +
    1.71 +
    1.72 +</script>
    1.73 +</pre>
    1.74 +</body>
    1.75 +</html>
    1.76 +

mercurial