Fix the search field if the inpsected Document has overridden Document.evalua...
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Feb 2008 18:37:49 +0000 (18:37 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Feb 2008 18:37:49 +0000 (18:37 +0000)
        Reviewed by Darin.

        * manual-tests/inspector-document-methods-override.html: Added.
        * page/InspectorController.cpp:
        (WebCore::InspectorController::didCommitLoad): Reworded a comment to
        force WebCore.vcproj to build.
        * page/inspector/inspector.js: Call
        Document.prototype.{evaluate,querySelectorAll}.call instead of calling
        the functions directly on the inspected Document. This ensures we are
        calling the version of these functions we intended to.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29965 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/manual-tests/inspector-document-methods-override.html [new file with mode: 0644]
WebCore/page/InspectorController.cpp
WebCore/page/inspector/inspector.js

index 02d03c3..0b9a2c0 100644 (file)
@@ -1,3 +1,19 @@
+2008-02-04  Adam Roben  <aroben@apple.com>
+
+        Fix the search field if the inpsected Document has overridden
+        Document.evaluate or Document.querySelectorAll
+
+        Reviewed by Darin.
+
+        * manual-tests/inspector-document-methods-override.html: Added.
+        * page/InspectorController.cpp:
+        (WebCore::InspectorController::didCommitLoad): Reworded a comment to
+        force WebCore.vcproj to build.
+        * page/inspector/inspector.js: Call
+        Document.prototype.{evaluate,querySelectorAll}.call instead of calling
+        the functions directly on the inspected Document. This ensures we are
+        calling the version of these functions we intended to.
+
 2008-02-04  Darin Adler  <darin@apple.com>
 
         Reviewed by Tim Hatcher.
diff --git a/WebCore/manual-tests/inspector-document-methods-override.html b/WebCore/manual-tests/inspector-document-methods-override.html
new file mode 100644 (file)
index 0000000..ca53f25
--- /dev/null
@@ -0,0 +1,14 @@
+<p>This page test that using the Web Inspector's search field on a page that
+overrides <tt>Document.evaluate</tt> or <tt>Document.querySelectorAll</tt>
+still works.<p>
+
+<p>To test, right-click on this page and select &ldquo;Inspect Element&rdquo;,
+then type &ldquo;p&rdquo; in the search field (without the quotes). If the
+search results list appears, then you have passed the test. If one or more
+alert dialogs appear, you have failed the test.</p>
+
+<script>
+    function fail() { alert('FAIL') }
+    document.querySelectorAll = fail;
+    document.evaluate = fail;
+</script>
index d71558b..b324e2b 100644 (file)
@@ -1350,8 +1350,10 @@ void InspectorController::didCommitLoad(DocumentLoader* loader)
                 // list of resources for the page they are navigating away from.
                 addAndUpdateScriptResource(m_mainResource.get());
             } else {
-                // Pages loaded from the page cache are commited before m_mainResource is the right
-                // resource for this load. Clear it and it will be assigned in identifierForInitialRequest.
+                // Pages loaded from the page cache are committed before
+                // m_mainResource is the right resource for this load, so we
+                // clear it here. It will be re-assigned in
+                // identifierForInitialRequest.
                 m_mainResource = 0;
             }
         }
index c82f40f..04e78e6 100644 (file)
@@ -890,13 +890,13 @@ WebInspector.performSearch = function(query)
         if (resource.category === this.resourceCategories.documents) {
             var doc = resource.documentNode;
             try {
-                var result = doc.evaluate(xpathQuery, doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
+                var result = Document.prototype.evaluate.call(doc, xpathQuery, doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
                 addNodesToDOMResults(result, result.snapshotLength, function(l, i) { return l.snapshotItem(i); });
             } catch(err) {
                 // ignore any exceptions. the query might be malformed, but we allow that.
             }
 
-            var result = doc.querySelectorAll(query);
+            var result = Document.prototype.querySelectorAll.call(doc, query);
             addNodesToDOMResults(result, result.length, function(l, i) { return l.item(i); });
 
             cleanUpDOMResultsNodes();