| Index: chrome/test/data/extensions/api_test/automation/tests/tabs/find.js
|
| diff --git a/chrome/test/data/extensions/api_test/automation/tests/tabs/find.js b/chrome/test/data/extensions/api_test/automation/tests/tabs/find.js
|
| index 4f0d98efc795a847c86eb2ec0b257997edcbf614..39b1d2a89f27dec0b3336ec908799368c1663211 100644
|
| --- a/chrome/test/data/extensions/api_test/automation/tests/tabs/find.js
|
| +++ b/chrome/test/data/extensions/api_test/automation/tests/tabs/find.js
|
| @@ -14,37 +14,37 @@ var cancelButton;
|
|
|
| function initializeNodes(rootNode) {
|
| group = rootNode.firstChild;
|
| - assertEq(RoleType.group, group.role);
|
| + assertEq(RoleType.GROUP, group.role);
|
|
|
| h1 = group.firstChild;
|
| - assertEq(RoleType.heading, h1.role);
|
| + assertEq(RoleType.HEADING, h1.role);
|
| assertEq(1, h1.hierarchicalLevel);
|
|
|
| p1 = group.lastChild;
|
| - assertEq(RoleType.paragraph, p1.role);
|
| + assertEq(RoleType.PARAGRAPH, p1.role);
|
|
|
| link = p1.children[1];
|
| - assertEq(RoleType.link, link.role);
|
| + assertEq(RoleType.LINK, link.role);
|
|
|
| main = rootNode.children[1];
|
| - assertEq(RoleType.main, main.role);
|
| + assertEq(RoleType.MAIN, main.role);
|
|
|
| p2 = main.firstChild;
|
| - assertEq(RoleType.paragraph, p2.role);
|
| + assertEq(RoleType.PARAGRAPH, p2.role);
|
|
|
| p3 = main.lastChild;
|
| - assertEq(RoleType.paragraph, p3.role);
|
| + assertEq(RoleType.PARAGRAPH, p3.role);
|
|
|
| okButton = rootNode.children[2];
|
| - assertEq(RoleType.button, okButton.role);
|
| + assertEq(RoleType.BUTTON, okButton.role);
|
| assertEq('Ok', okButton.name);
|
| - assertTrue(StateType.disabled in okButton.state);
|
| + assertTrue(StateType.DISABLED in okButton.state);
|
| assertTrue(okButton.state.disabled);
|
|
|
| cancelButton = rootNode.children[3];
|
| - assertEq(RoleType.button, cancelButton.role);
|
| + assertEq(RoleType.BUTTON, cancelButton.role);
|
| assertEq('Cancel', cancelButton.name);
|
| - assertFalse(StateType.disabled in cancelButton.state);
|
| + assertFalse(StateType.DISABLED in cancelButton.state);
|
| }
|
|
|
| var allTests = [
|
| @@ -52,26 +52,26 @@ var allTests = [
|
| initializeNodes(rootNode);
|
|
|
| // Should find the only instance of this role.
|
| - assertEq(h1, rootNode.find({ role: RoleType.heading}));
|
| - assertEq([h1], rootNode.findAll({ role: RoleType.heading}));
|
| + assertEq(h1, rootNode.find({role: RoleType.HEADING}));
|
| + assertEq([h1], rootNode.findAll({role: RoleType.HEADING}));
|
|
|
| // find should find first instance only.
|
| - assertEq(okButton, rootNode.find({ role: RoleType.button }));
|
| - assertEq(p1, rootNode.find({ role: RoleType.paragraph }));
|
| + assertEq(okButton, rootNode.find({role: RoleType.BUTTON}));
|
| + assertEq(p1, rootNode.find({role: RoleType.PARAGRAPH}));
|
|
|
| // findAll should find all instances.
|
| - assertEq([okButton, cancelButton],
|
| - rootNode.findAll({ role: RoleType.button }));
|
| - assertEq([p1, p2, p3], rootNode.findAll({ role: RoleType.paragraph }));
|
| + assertEq(
|
| + [okButton, cancelButton], rootNode.findAll({role: RoleType.BUTTON}));
|
| + assertEq([p1, p2, p3], rootNode.findAll({role: RoleType.PARAGRAPH}));
|
|
|
| // No instances: find should return null; findAll should return empty array.
|
| - assertEq(null, rootNode.find({ role: RoleType.checkbox }));
|
| - assertEq([], rootNode.findAll({ role: RoleType.checkbox }));
|
| + assertEq(null, rootNode.find({role: RoleType.CHECKBOX}));
|
| + assertEq([], rootNode.findAll({role: RoleType.CHECKBOX}));
|
|
|
| // Calling from node should search only its subtree.
|
| - assertEq(p1, group.find({ role: RoleType.paragraph }));
|
| - assertEq(p2, main.find({ role: RoleType.paragraph }));
|
| - assertEq([p2, p3], main.findAll({ role: RoleType.paragraph }));
|
| + assertEq(p1, group.find({role: RoleType.PARAGRAPH}));
|
| + assertEq(p2, main.find({role: RoleType.PARAGRAPH}));
|
| + assertEq([p2, p3], main.findAll({role: RoleType.PARAGRAPH}));
|
|
|
| chrome.test.succeed();
|
| },
|
| @@ -80,21 +80,25 @@ var allTests = [
|
| initializeNodes(rootNode);
|
|
|
| // Find all focusable elements (disabled button is not focusable).
|
| - assertEq(link, rootNode.find({ state: { focusable: true }}));
|
| - assertEq([link, cancelButton],
|
| - rootNode.findAll({ state: { focusable: true }}));
|
| + assertEq(link, rootNode.find({state: {focusable: true}}));
|
| + assertEq(
|
| + [link, cancelButton], rootNode.findAll({state: {focusable: true}}));
|
|
|
| // Find disabled buttons.
|
| - assertEq(okButton, rootNode.find({ role: RoleType.button,
|
| - state: { disabled: true }}));
|
| - assertEq([okButton], rootNode.findAll({ role: RoleType.button,
|
| - state: { disabled: true }}));
|
| + assertEq(
|
| + okButton,
|
| + rootNode.find({role: RoleType.BUTTON, state: {disabled: true}}));
|
| + assertEq(
|
| + [okButton],
|
| + rootNode.findAll({role: RoleType.BUTTON, state: {disabled: true}}));
|
|
|
| // Find enabled buttons.
|
| - assertEq(cancelButton, rootNode.find({ role: RoleType.button,
|
| - state: { disabled: false }}));
|
| - assertEq([cancelButton], rootNode.findAll({ role: RoleType.button,
|
| - state: { disabled: false }}));
|
| + assertEq(
|
| + cancelButton,
|
| + rootNode.find({role: RoleType.BUTTON, state: {disabled: false}}));
|
| + assertEq(
|
| + [cancelButton],
|
| + rootNode.findAll({role: RoleType.BUTTON, state: {disabled: false}}));
|
| chrome.test.succeed();
|
| },
|
|
|
| @@ -102,59 +106,71 @@ var allTests = [
|
| initializeNodes(rootNode);
|
|
|
| // Find by name attribute.
|
| - assertEq(okButton, rootNode.find({ attributes: { name: 'Ok' }}));
|
| - assertEq(cancelButton, rootNode.find({ attributes: { name: 'Cancel' }}));
|
| + assertEq(okButton, rootNode.find({attributes: {name: 'Ok'}}));
|
| + assertEq(cancelButton, rootNode.find({attributes: {name: 'Cancel'}}));
|
|
|
| // String attributes must be exact match unless a regex is used.
|
| - assertEq(null, rootNode.find({ attributes: { name: 'Canc' }}));
|
| - assertEq(null, rootNode.find({ attributes: { name: 'ok' }}));
|
| + assertEq(null, rootNode.find({attributes: {name: 'Canc'}}));
|
| + assertEq(null, rootNode.find({attributes: {name: 'ok'}}));
|
|
|
| // Find by value attribute - regexp.
|
| - var query = { attributes: { name: /relationship/ }};
|
| + var query = {attributes: {name: /relationship/}};
|
| assertEq(p2, rootNode.find(query).parent);
|
|
|
| // Find by role and hierarchicalLevel attribute.
|
| - assertEq(h1, rootNode.find({ role: RoleType.heading,
|
| - attributes: { hierarchicalLevel: 1 }}));
|
| - assertEq([], rootNode.findAll({ role: RoleType.heading,
|
| - attributes: { hierarchicalLevel: 2 }}));
|
| + assertEq(
|
| + h1, rootNode.find(
|
| + {role: RoleType.HEADING, attributes: {hierarchicalLevel: 1}}));
|
| + assertEq(
|
| + [], rootNode.findAll(
|
| + {role: RoleType.HEADING, attributes: {hierarchicalLevel: 2}}));
|
|
|
| // Searching for an attribute which no element has fails.
|
| - assertEq(null, rootNode.find({ attributes: { charisma: 12 } }));
|
| + assertEq(null, rootNode.find({attributes: {charisma: 12}}));
|
|
|
| // Searching for an attribute value of the wrong type fails (even if the
|
| // value is equivalent).
|
| - assertEq(null, rootNode.find({ role: RoleType.heading,
|
| - attributes: { hierarchicalLevel: true }} ));
|
| + assertEq(
|
| + null,
|
| + rootNode.find(
|
| + {role: RoleType.HEADING, attributes: {hierarchicalLevel: true}}));
|
|
|
| chrome.test.succeed();
|
| },
|
|
|
| function testMatches() {
|
| initializeNodes(rootNode);
|
| - assertTrue(h1.matches({ role: RoleType.heading }),
|
| - 'h1 should match RoleType.heading');
|
| - assertTrue(h1.matches({ role: RoleType.heading,
|
| - attributes: { hierarchicalLevel: 1 } }),
|
| - 'h1 should match RoleType.heading and hierarchicalLevel: 1');
|
| - assertFalse(h1.matches({ role: RoleType.heading,
|
| - state: { focusable: true },
|
| - attributes: { hierarchicalLevel: 1 } }),
|
| - 'h1 should not match focusable: true');
|
| - assertTrue(h1.matches({ role: RoleType.heading,
|
| - state: { focusable: false },
|
| - attributes: { hierarchicalLevel: 1 } }),
|
| - 'h1 should match focusable: false');
|
| + assertTrue(
|
| + h1.matches({role: RoleType.HEADING}),
|
| + 'h1 should match RoleType.HEADING');
|
| + assertTrue(
|
| + h1.matches(
|
| + {role: RoleType.HEADING, attributes: {hierarchicalLevel: 1}}),
|
| + 'h1 should match RoleType.HEADING and hierarchicalLevel: 1');
|
| + assertFalse(
|
| + h1.matches({
|
| + role: RoleType.HEADING,
|
| + state: {focusable: true},
|
| + attributes: {hierarchicalLevel: 1}
|
| + }),
|
| + 'h1 should not match focusable: true');
|
| + assertTrue(
|
| + h1.matches({
|
| + role: RoleType.HEADING,
|
| + state: {focusable: false},
|
| + attributes: {hierarchicalLevel: 1}
|
| + }),
|
| + 'h1 should match focusable: false');
|
|
|
| var p2StaticText = p2.firstChild;
|
| assertTrue(
|
| - p2StaticText.matches({ role: RoleType.staticText,
|
| - attributes: { name: /relationship/ } }),
|
| + p2StaticText.matches(
|
| + {role: RoleType.STATIC_TEXT, attributes: {name: /relationship/}}),
|
| 'p2StaticText should match name: /relationship/ (regex match)');
|
| assertFalse(
|
| - p2StaticText.matches({ role: RoleType.staticText,
|
| - attributes: { name: 'relationship' } }),
|
| - 'p2 should not match name: \'relationship');
|
| + p2StaticText.matches(
|
| + {role: RoleType.STATIC_TEXT, attributes: {name: 'relationship'}}),
|
| + 'p2 should not match name: \'relationship');
|
|
|
| chrome.test.succeed();
|
| }
|
|
|