Title: [100246] trunk
- Revision
- 100246
- Author
- [email protected]
- Date
- 2011-11-15 00:08:59 -0800 (Tue, 15 Nov 2011)
Log Message
Web Inspector: Command line $x fails for 3 of 4 types of XPath query
https://bugs.webkit.org/show_bug.cgi?id=72276
Reviewed by Timothy Hatcher.
Source/WebCore:
Test: inspector/console/console-xpath.html
* inspector/InjectedScriptSource.js:
(.):
LayoutTests:
* inspector/console/console-xpath-expected.txt: Added.
* inspector/console/console-xpath.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (100245 => 100246)
--- trunk/LayoutTests/ChangeLog 2011-11-15 07:10:06 UTC (rev 100245)
+++ trunk/LayoutTests/ChangeLog 2011-11-15 08:08:59 UTC (rev 100246)
@@ -1,3 +1,13 @@
+2011-11-14 Pavel Feldman <[email protected]>
+
+ Web Inspector: Command line $x fails for 3 of 4 types of XPath query
+ https://bugs.webkit.org/show_bug.cgi?id=72276
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/console/console-xpath-expected.txt: Added.
+ * inspector/console/console-xpath.html: Added.
+
2011-11-14 Peter Kasting <[email protected]>
r100237 moved some pixel baselines into platform/chromium without also
Added: trunk/LayoutTests/inspector/console/console-xpath-expected.txt (0 => 100246)
--- trunk/LayoutTests/inspector/console/console-xpath-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/console/console-xpath-expected.txt 2011-11-15 08:08:59 UTC (rev 100246)
@@ -0,0 +1,13 @@
+CONSOLE MESSAGE: line 1: complete
+Tests $x for iterator and non-iterator types.
+
+$x('42')
+$x('name(/html)')
+$x('not(42)')
+$x('/html/body/p').length
+42
+"html"
+false
+1
+complete
+
Property changes on: trunk/LayoutTests/inspector/console/console-xpath-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/inspector/console/console-xpath.html (0 => 100246)
--- trunk/LayoutTests/inspector/console/console-xpath.html (rev 0)
+++ trunk/LayoutTests/inspector/console/console-xpath.html 2011-11-15 08:08:59 UTC (rev 100246)
@@ -0,0 +1,35 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function test()
+{
+ InspectorTest.addConsoleSniffer(addMessageSniffer, true);
+
+ InspectorTest.evaluateInConsole("$x('42')"); // number
+ InspectorTest.evaluateInConsole("$x('name(/html)')"); // string
+ InspectorTest.evaluateInConsole("$x('not(42)')"); // boolean
+ InspectorTest.evaluateInConsole("$x('/html/body/p').length"); // node iterator
+ InspectorTest.evaluateInPage("console.log('complete')"); // node iterator
+
+ function addMessageSniffer(message)
+ {
+ if (message.toString().indexOf("complete") !== -1) {
+ InspectorTest.dumpConsoleMessages();
+ InspectorTest.completeTest();
+ }
+ }
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Tests $x for iterator and non-iterator types.
+</p>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/console/console-xpath.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (100245 => 100246)
--- trunk/Source/WebCore/ChangeLog 2011-11-15 07:10:06 UTC (rev 100245)
+++ trunk/Source/WebCore/ChangeLog 2011-11-15 08:08:59 UTC (rev 100246)
@@ -1,3 +1,15 @@
+2011-11-14 Pavel Feldman <[email protected]>
+
+ Web Inspector: Command line $x fails for 3 of 4 types of XPath query
+ https://bugs.webkit.org/show_bug.cgi?id=72276
+
+ Reviewed by Timothy Hatcher.
+
+ Test: inspector/console/console-xpath.html
+
+ * inspector/InjectedScriptSource.js:
+ (.):
+
2011-11-14 Ryosuke Niwa <[email protected]>
Fix the change log entry for r59190.
Modified: trunk/Source/WebCore/inspector/InjectedScriptSource.js (100245 => 100246)
--- trunk/Source/WebCore/inspector/InjectedScriptSource.js 2011-11-15 07:10:06 UTC (rev 100245)
+++ trunk/Source/WebCore/inspector/InjectedScriptSource.js 2011-11-15 08:08:59 UTC (rev 100246)
@@ -592,16 +592,22 @@
$x: function(xpath, context)
{
- var nodes = [];
- try {
- var doc = (context && context.ownerDocument) || inspectedWindow.document;
- var results = doc.evaluate(xpath, context || doc, null, XPathResult.ANY_TYPE, null);
+ var doc = (context && context.ownerDocument) || inspectedWindow.document;
+ var result = doc.evaluate(xpath, context || doc, null, XPathResult.ANY_TYPE, null);
+ switch (result.resultType) {
+ case XPathResult.NUMBER_TYPE:
+ return result.numberValue;
+ case XPathResult.STRING_TYPE:
+ return result.stringValue;
+ case XPathResult.BOOLEAN_TYPE:
+ return result.booleanValue;
+ default:
+ var nodes = [];
var node;
- while (node = results.iterateNext())
+ while (node = result.iterateNext())
nodes.push(node);
- } catch (e) {
+ return nodes;
}
- return nodes;
},
dir: function()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes