roles-dynamic-switch.tentative.window.js (2649B)
1 // META: script=/resources/testdriver.js 2 // META: script=/resources/testdriver-vendor.js 3 // META: script=/resources/testdriver-actions.js 4 5 promise_test(async () => { 6 const control = document.createElement("input"); 7 control.type = "checkbox"; 8 control.switch = true; 9 const role = await test_driver.get_computed_role(control); 10 assert_equals(role, ""); 11 }, `Disconnected <input type=checkbox switch>`); 12 13 promise_test(async t => { 14 const control = document.createElement("input"); 15 t.add_cleanup(() => control.remove()); 16 control.type = "checkbox"; 17 control.switch = true; 18 document.body.append(control); 19 const role = await test_driver.get_computed_role(control); 20 assert_equals(role, "switch"); 21 }, `Connected <input type=checkbox switch>`); 22 23 promise_test(async t => { 24 const control = document.createElement("input"); 25 t.add_cleanup(() => control.remove()); 26 control.type = "checkbox"; 27 document.body.append(control); 28 let role = await test_driver.get_computed_role(control); 29 assert_equals(role, "checkbox"); 30 control.switch = true; 31 role = await test_driver.get_computed_role(control); 32 assert_equals(role, "switch"); 33 }, `Connected <input type=checkbox switch>: adding switch attribute`); 34 35 promise_test(async t => { 36 const control = document.createElement("input"); 37 t.add_cleanup(() => control.remove()); 38 control.type = "checkbox"; 39 control.switch = true; 40 document.body.append(control); 41 let role = await test_driver.get_computed_role(control); 42 assert_equals(role, "switch"); 43 control.switch = false; 44 role = await test_driver.get_computed_role(control); 45 assert_equals(role, "checkbox"); 46 }, `Connected <input type=checkbox switch>: removing switch attribute`); 47 48 promise_test(async t => { 49 const control = document.createElement("input"); 50 t.add_cleanup(() => control.remove()); 51 control.type = "checkbox"; 52 document.body.append(control); 53 control.switch = true; 54 let role = await test_driver.get_computed_role(control); 55 assert_equals(role, "switch"); 56 control.removeAttribute("type"); 57 role = await test_driver.get_computed_role(control); 58 assert_equals(role, "textbox"); 59 }, `Connected <input type=checkbox switch>: removing type attribute`); 60 61 promise_test(async t => { 62 const control = document.createElement("input"); 63 t.add_cleanup(() => control.remove()); 64 control.switch = true; 65 document.body.append(control); 66 let role = await test_driver.get_computed_role(control); 67 assert_equals(role, "textbox"); 68 control.type = "checkbox"; 69 role = await test_driver.get_computed_role(control); 70 assert_equals(role, "switch"); 71 }, `Connected <input type=checkbox switch>: adding type attribute`);