dom/filesystem/tests/test_bug1319088.html
author Adam Pucciano <aspucciano@myseneca.ca>
Wed, 05 Dec 2018 02:24:58 +0000
changeset 449368 3930f1e2fc9e26f09c9722a941cb77bb28956d0d
parent 344947 a072d7934ff7c6fd2ad974d7abc0b08d11041aca
child 469658 ba6f655fd68963530c866d0d4a48c3db3d307777
permissions -rw-r--r--
Bug 1508989 - Enable ESLint for dom/filesystem / (automatic changes) r=Standard8 Differential Revision: https://phabricator.services.mozilla.com/D13770

<!DOCTYPE HTML>
<html>
<head>
  <title>Test for bug 1319088</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>

<body>
<input id="input" type="file"></input>

<script type="application/javascript">

function testSetup() {
  SpecialPowers.pushPrefEnv({"set": [["dom.input.dirpicker", true],
                                     ["dom.webkitBlink.dirPicker.enabled", true]]}, next);
}

function populateInputFile() {
  var url = SimpleTest.getTestFileURL("script_fileList.js");
  var script = SpecialPowers.loadChromeScript(url);

  function onOpened(message) {
    var input = document.getElementById("input");
    SpecialPowers.wrap(input).mozSetFileArray([message.file]);

    script.destroy();
    next();
  }

  script.addMessageListener("file.opened", onOpened);
  script.sendAsyncMessage("file.open");
}

function checkBug() {
  var input = document.getElementById("input");
  is(input.files[0].webkitRelativePath, "", "No relative path!");

  let form = document.createElement("form");
  form.appendChild(input);

  is(input.files[0].webkitRelativePath, "", "No relative path!");
  SimpleTest.finish();
}

var tests = [
  testSetup,
  populateInputFile,
  checkBug,
];

function next() {
  if (!tests.length) {
    SimpleTest.finish();
    return;
  }

  var test = tests.shift();
  test();
}

SimpleTest.waitForExplicitFinish();
next();
</script>
</body>
</html>