Index: chrome/test/data/extensions/api_test/automation/tests/tabs/queryselector.js |
diff --git a/chrome/test/data/extensions/api_test/automation/tests/tabs/queryselector.js b/chrome/test/data/extensions/api_test/automation/tests/tabs/queryselector.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b9078f132f7c527ef67b49cce1a72c7f860e82e6 |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/automation/tests/tabs/queryselector.js |
@@ -0,0 +1,55 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+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.
|
+ // Basic query from root node. |
+ function testQuerySelector() { |
+ var cancelButton = rootNode.lastChild().lastChild(); |
+ 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
|
+ assertEq(queryResult, cancelButton); |
+ chrome.test.succeed(); |
+ } |
+ rootNode.querySelector('body > button:nth-of-type(2)', |
+ assertCorrectResult); |
+ }, |
+ |
+ // Demonstrates that a query from a non-root element queries inside that |
+ // element. |
+ function testQuerySelectorFromMain() { |
+ var main = rootNode.children()[1]; |
+ console.log('main: ' + main.toString()); |
+ // paragraph inside "main" element - not the first <p> on the page |
+ var p = main.firstChild(); |
+ function assertCorrectResult(queryResult) { |
+ assertEq(queryResult, p); |
+ chrome.test.succeed(); |
+ } |
+ main.querySelector('p', assertCorrectResult); |
+ }, |
+ |
+ // Demonstrates that a query for an element which is ignored for accessibility |
+ // returns its nearest ancestor. |
+ function testQuerySelectorForSpanInsideButtonReturnsButton() { |
+ var okButton = rootNode.lastChild().firstChild(); |
+ function assertCorrectResult(queryResult) { |
+ assertEq(queryResult, okButton); |
+ chrome.test.succeed(); |
+ } |
+ rootNode.querySelector('#span-in-button', assertCorrectResult); |
+ }, |
+ |
+ // Demonstrates that querying from an anonymous node may have unexpected |
+ // results. |
+ function testQuerySelectorFromAnonymousGroup() { |
+ var h1 = rootNode.firstChild().firstChild(); |
+ var group = rootNode.lastChild(); |
+ function assertCorrectResult(queryResult) { |
+ assertEq(queryResult, h1); |
+ chrome.test.succeed(); |
+ } |
+ group.querySelector('h1', assertCorrectResult); |
+ } |
+]; |
+ |
+setUpAndRunTests(allTests, 'complex.html'); |