DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (3b823d058ef5)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
<!doctype html>
<meta charset=utf-8>
<title></title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<input type="radio" name="group" id="lightRadio1">
<input type="radio" name="group" id="lightRadio2">
<div id="host"></div>
<script>

test(() => {
    var lightRadio1 = document.getElementById("lightRadio1");
    var lightRadio2 = document.getElementById("lightRadio2");

    var host = document.getElementById("host");
    var sr = host.attachShadow({mode: "closed"});
    var shadowRadio1 = document.createElement("input");
    shadowRadio1.name = "group";
    shadowRadio1.id = "shadowRadio1";
    shadowRadio1.type = "radio";
    sr.appendChild(shadowRadio1);
    var shadowRadio2 = document.createElement("input");
    shadowRadio2.name = "group";
    shadowRadio2.id = "shadowRadio2";
    shadowRadio2.type = "radio";
    sr.appendChild(shadowRadio2);

    assert_false(lightRadio1.checked);
    assert_false(lightRadio2.checked);
    assert_false(shadowRadio1.checked);
    assert_false(shadowRadio2.checked);

    lightRadio1.click();
    assert_true(lightRadio1.checked);
    assert_false(lightRadio2.checked);
    assert_false(shadowRadio1.checked);
    assert_false(shadowRadio2.checked);

    lightRadio2.click();
    assert_false(lightRadio1.checked);
    assert_true(lightRadio2.checked);
    assert_false(shadowRadio1.checked);
    assert_false(shadowRadio2.checked);

    shadowRadio1.click();
    assert_false(lightRadio1.checked);
    assert_true(lightRadio2.checked);
    assert_true(shadowRadio1.checked);
    assert_false(shadowRadio2.checked);

    shadowRadio2.click();
    assert_false(lightRadio1.checked);
    assert_true(lightRadio2.checked);
    assert_false(shadowRadio1.checked);
    assert_true(shadowRadio2.checked);

    // Ensure radio groups work even when modifying shadow DOM.
    shadowRadio2.remove();
    sr.appendChild(shadowRadio2);
    shadowRadio2.click();
    assert_false(lightRadio1.checked);
    assert_true(lightRadio2.checked);
    assert_false(shadowRadio1.checked);
    assert_true(shadowRadio2.checked);

    shadowRadio1.click();
    assert_false(lightRadio1.checked);
    assert_true(lightRadio2.checked);
    assert_true(shadowRadio1.checked);
    assert_false(shadowRadio2.checked);
}, "input type=radio elements should form a group inside shadow DOM.");

</script>