toolkit/components/payments/test/mochitest/test_labelled_checkbox.html
author Cosmin Sabou <csabou@mozilla.com>
Fri, 27 Apr 2018 08:37:29 +0300
changeset 472049 9424d87854e4f1783435e5a3c2e58189197d2936
parent 472015 browser/components/payments/test/mochitest/test_labelled_checkbox.html@a8fef63084795665c01e9753fb8647b71e9c0331
permissions -rw-r--r--
Backed out 2 changesets (bug 1457287) for browser chrome failures on browser_address_edit.js. CLOSED TREE Backed out changeset 0ae9810db352 (bug 1457287) Backed out changeset a8fef6308479 (bug 1457287)

<!DOCTYPE HTML>
<html>
<!--
Test the labelled-checkbox component
-->
<head>
  <meta charset="utf-8">
  <title>Test the labelled-checkbox component</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
  <script src="payments_common.js"></script>
  <script src="../../res/vendor/custom-elements.min.js"></script>

  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
  <p id="display">
    <labelled-checkbox id="box0"></labelled-checkbox>
    <labelled-checkbox id="box1" label="the label" value="the value"></labelled-checkbox>
  </p>
<div id="content" style="display: none">

</div>
<pre id="test">
</pre>
<script type="module">
/** Test the labelled-checkbox component **/

/* import-globals-from payments_common.js */
import "../../res/components/labelled-checkbox.js";

let box0 = document.getElementById("box0");
let box1 = document.getElementById("box1");

add_task(async function test_no_values() {
  ok(box0, "box0 exists");
  is(box0.label, null, "Initially un-labelled");
  is(box0.value, null, "Check .value");
  ok(!box0.checked, "Initially is not checked");
  ok(!box0.querySelector("input:checked"), "has no checked inner input");

  box0.checked = true;
  box0.value = "New value";
  box0.label = "New label";

  await asyncElementRendered();

  ok(box0.checked, "Becomes checked");
  ok(box0.querySelector("input:checked"), "has a checked inner input");
  is(box0.getAttribute("label"), "New label", "Assigned label");
  is(box0.getAttribute("value"), "New value", "Assigned value");
});

add_task(async function test_initial_values() {
  is(box1.label, "the label", "Initial label");
  is(box1.value, "the value", "Initial value");
  ok(!box1.checked, "Initially unchecked");
  ok(!box1.querySelector("input:checked"), "has no checked inner input");

  box1.checked = false;
  box1.value = "New value";
  box1.label = "New label";

  await asyncElementRendered();

  ok(!box1.checked, "Checked property remains falsey");
  is(box1.getAttribute("value"), "New value", "Assigned value");
  is(box1.getAttribute("label"), "New label", "Assigned label");
});

</script>

</body>
</html>