Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: chrome/test/data/extensions/api_test/automation/tests/tabs/queryselector.js

Issue 655273005: Implement AutomationNode.querySelector(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Address review comments and flesh out error and edge case handling Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var allTests = [
dmazzoni 2014/10/30 23:32:42 How about a test where the query string doesn't re
aboxhall 2014/10/31 20:32:22 Good idea, done.
6 // Basic query from root node.
7 function testQuerySelector() {
8 var cancelButton = rootNode.lastChild().lastChild();
9 function assertCorrectResult(queryResult) {
Devlin 2014/10/30 23:26:53 I'm not too passionate about it, but is there a re
aboxhall 2014/10/31 20:32:22 No real reason here, but I'm in the habit of doing
10 assertEq(queryResult, cancelButton);
11 chrome.test.succeed();
12 }
13 rootNode.querySelector('body > button:nth-of-type(2)',
14 assertCorrectResult);
15 },
16
17 // Demonstrates that a query from a non-root element queries inside that
18 // element.
19 function testQuerySelectorFromMain() {
20 var main = rootNode.children()[1];
21 console.log('main: ' + main.toString());
22 // paragraph inside "main" element - not the first <p> on the page
23 var p = main.firstChild();
24 function assertCorrectResult(queryResult) {
25 assertEq(queryResult, p);
26 chrome.test.succeed();
27 }
28 main.querySelector('p', assertCorrectResult);
29 },
30
31 // Demonstrates that a query for an element which is ignored for accessibility
32 // returns its nearest ancestor.
33 function testQuerySelectorForSpanInsideButtonReturnsButton() {
34 var okButton = rootNode.lastChild().firstChild();
35 function assertCorrectResult(queryResult) {
36 assertEq(queryResult, okButton);
37 chrome.test.succeed();
38 }
39 rootNode.querySelector('#span-in-button', assertCorrectResult);
40 },
41
42 // Demonstrates that querying from an anonymous node may have unexpected
43 // results.
44 function testQuerySelectorFromAnonymousGroup() {
45 var h1 = rootNode.firstChild().firstChild();
46 var group = rootNode.lastChild();
47 function assertCorrectResult(queryResult) {
48 assertEq(queryResult, h1);
49 chrome.test.succeed();
50 }
51 group.querySelector('h1', assertCorrectResult);
52 }
53 ];
54
55 setUpAndRunTests(allTests, 'complex.html');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698