dom/devicestorage/test/test_watchOther.html

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     1 <!--
     2   Any copyright is dedicated to the Public Domain.
     3   http://creativecommons.org/publicdomain/zero/1.0/
     4 -->
     5 <!DOCTYPE HTML>
     6 <html> <!--
     7 https://bugzilla.mozilla.org/show_bug.cgi?id=717103
     8 -->
     9 <head>
    10   <title>Test for the device storage API </title>
    11   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    12   <script type="text/javascript" src="devicestorage_common.js"></script>
    14 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    15 </head>
    16 <body>
    17 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717103">Mozilla Bug 717103</a>
    18 <p id="display"></p>
    19 <div id="content" style="display: none">
    21 </div>
    22 <pre id="test">
    23 <script class="testbody" type="text/javascript">
    25 devicestorage_setup();
    27 var gFileName = randomFilename(20) + ".png"
    29 function addSuccess(e) {
    30 }
    32 function addError(e) {
    33   ok(false, "addError was called : " + e.target.error.name);
    34   devicestorage_cleanup();
    35 }
    37 function onChange(e) {
    39   dump("we saw: " + e.path + " " + e.reason + "\n");
    41   var filename = e.path;
    42   if (filename[0] == "/") {
    43     // We got /storageName/prefix/filename
    44     // Remove the storageName (this shows up on FirefoxOS)
    45     filename = filename.substring(1); // Remove leading slash
    46     var slashIndex = filename.indexOf("/");
    47     if (slashIndex >= 0) {
    48       filename = filename.substring(slashIndex + 1); // Remove storageName
    49     }
    50   }
    51   if (filename == gFileName) {
    52     ok(true, "we saw the file get created");
    53     storage.removeEventListener("change", onChange);
    54     devicestorage_cleanup();
    55   }
    56   else {
    57     // we may see other file changes during the test, and
    58     // that is completely ok
    59   }
    60 }
    62 function onChangeFail(e) {
    63   dump("onChangeFail: " + e.path + " " + e.reason + "\n");
    64   ok(false, "We should never see any changes");
    65 }
    67 var storage = navigator.getDeviceStorage("pictures");
    68 ok(storage, "Should have storage");
    69 storage.addEventListener("change", onChange);
    71 var storageOther = navigator.getDeviceStorage("music");
    72 ok(storageOther, "Should have storage");
    73 storageOther.addEventListener("change", onChangeFail);
    75 request = storage.addNamed(createRandomBlob('image/png'), gFileName);
    76 ok(request, "Should have a non-null request");
    78 request.onsuccess = addSuccess;
    79 request.onerror = addError;
    81 </script>
    82 </pre>
    83 </body>
    84 </html>

mercurial