// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=/resources/testdriver-actions.js
promise_test(async () => {
const control = document.createElement("input");
control.type = "checkbox";
control.switch = true;
const role = await test_driver.get_computed_role(control);
assert_equals(role, "");
}, `Disconnected `);
promise_test(async t => {
const control = document.createElement("input");
t.add_cleanup(() => control.remove());
control.type = "checkbox";
control.switch = true;
document.body.append(control);
const role = await test_driver.get_computed_role(control);
assert_equals(role, "switch");
}, `Connected `);
promise_test(async t => {
const control = document.createElement("input");
t.add_cleanup(() => control.remove());
control.type = "checkbox";
document.body.append(control);
let role = await test_driver.get_computed_role(control);
assert_equals(role, "checkbox");
control.switch = true;
role = await test_driver.get_computed_role(control);
assert_equals(role, "switch");
}, `Connected : adding switch attribute`);
promise_test(async t => {
const control = document.createElement("input");
t.add_cleanup(() => control.remove());
control.type = "checkbox";
control.switch = true;
document.body.append(control);
let role = await test_driver.get_computed_role(control);
assert_equals(role, "switch");
control.switch = false;
role = await test_driver.get_computed_role(control);
assert_equals(role, "checkbox");
}, `Connected : removing switch attribute`);
promise_test(async t => {
const control = document.createElement("input");
t.add_cleanup(() => control.remove());
control.type = "checkbox";
document.body.append(control);
control.switch = true;
let role = await test_driver.get_computed_role(control);
assert_equals(role, "switch");
control.removeAttribute("type");
role = await test_driver.get_computed_role(control);
assert_equals(role, "textbox");
}, `Connected : removing type attribute`);
promise_test(async t => {
const control = document.createElement("input");
t.add_cleanup(() => control.remove());
control.switch = true;
document.body.append(control);
let role = await test_driver.get_computed_role(control);
assert_equals(role, "textbox");
control.type = "checkbox";
role = await test_driver.get_computed_role(control);
assert_equals(role, "switch");
}, `Connected : adding type attribute`);