dom/filehandle/test/test_readonly_lockedfiles.html
author Jan Varga <jan.varga@gmail.com>
Wed, 07 May 2014 16:32:12 +0200
changeset 201268 03fdda1af1f4fc0bdf7bd71c765b89216a5a2737
parent 150375 dom/file/test/test_readonly_lockedfiles.html@c6ecfbeb6553f84a823f2d1f23b126df18bce952
permissions -rw-r--r--
Bug 975696 - Split ArchiveReader and FileHandle implementation into separate dirs. r=bent f=baku

<!--
  Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
  <title>File Handle Test</title>

  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>

  <script type="text/javascript;version=1.7">
  function testSteps()
  {
    for each (let fileStorage in fileStorages) {
      let request = getFileHandle(fileStorage.key, "test.txt");
      request.onerror = errorHandler;
      request.onsuccess = grabEventAndContinueHandler;
      let event = yield undefined;

      let fileHandle = event.target.result;
      fileHandle.onerror = errorHandler;

      request = fileHandle.open("readwrite").write({});
      request.onsuccess = grabEventAndContinueHandler;
      event = yield undefined;

      is(event.target.lockedFile.mode, "readwrite", "Correct mode");

      try {
        fileHandle.open().write({});
        ok(false, "Writing to a readonly locked file should fail!");
      }
      catch (e) {
        ok(true, "Writing to a readonly locked file failed");
      }

      try {
        fileHandle.open().append({});
        ok(false, "Appending to a readonly locked file should fail!");
      }
      catch (e) {
        ok(true, "Appending to a readonly locked file failed");
      }

      try {
        fileHandle.open().truncate({});
        ok(false, "Truncating a readonly locked file should fail!");
      }
      catch (e) {
        ok(true, "Truncating a readonly locked file failed");
      }

      try {
        fileHandle.open().flush({});
        ok(false, "Flushing a readonly locked file should fail!");
      }
      catch (e) {
        ok(true, "Flushing a readonly locked file failed");
      }
    }

    finishTest();
    yield undefined;
  }
  </script>
  <script type="text/javascript;version=1.7" src="helpers.js"></script>

</head>

<body onload="runTest();"></body>

</html>