[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9

eric at webkit.org eric at webkit.org
Thu Feb 4 21:27:26 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit abc4fbae6eb2356a9093181e5e1d91b838c254aa
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jan 25 18:57:40 2010 +0000

    2010-01-25  Yury Semikhatsky  <yurys at chromium.org>
    
            Reviewed by Timothy Hatcher.
    
            Test that Web Inspector doesn't change methods declared by the inspected
            page.
            https://bugs.webkit.org/show_bug.cgi?id=34089
    
            * inspector/inspected-objects-not-overriden-expected.txt: Added.
            * inspector/inspected-objects-not-overriden.html: Added.
    2010-01-25  Yury Semikhatsky  <yurys at chromium.org>
    
            Reviewed by Timothy Hatcher.
    
            Instead of adding inspector methods to the inspected global objects
            use private implementation visible from inspector code only.
            https://bugs.webkit.org/show_bug.cgi?id=34089
    
            Test: inspector/inspected-objects-not-overriden.html
    
            * inspector/front-end/InjectedScript.js:
            (injectedScriptConstructor):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53807 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index debe134..f3ca6da 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2010-01-25  Yury Semikhatsky  <yurys at chromium.org>
+
+        Reviewed by Timothy Hatcher.
+
+        Test that Web Inspector doesn't change methods declared by the inspected
+        page.
+        https://bugs.webkit.org/show_bug.cgi?id=34089
+
+        * inspector/inspected-objects-not-overriden-expected.txt: Added.
+        * inspector/inspected-objects-not-overriden.html: Added.
+
 2010-01-25  Philippe Normand  <pnormand at igalia.com>
 
         Rubber-stamped by Xan Lopez.
diff --git a/LayoutTests/inspector/inspected-objects-not-overriden-expected.txt b/LayoutTests/inspector/inspected-objects-not-overriden-expected.txt
new file mode 100644
index 0000000..cacedcc
--- /dev/null
+++ b/LayoutTests/inspector/inspected-objects-not-overriden-expected.txt
@@ -0,0 +1,10 @@
+Tests that opening inspector front-end doesn't change methods defined by the inspected application.
+
+myImpl() => my value
+Object.type === myImpl => true
+Object.hasProperties === myImpl => true
+Object.describe === myImpl => true
+Object.className === myImpl => true
+String.prototype.escapeCharacters === myImpl => true
+JSON.stringify === myImpl => true
+
diff --git a/LayoutTests/inspector/inspected-objects-not-overriden.html b/LayoutTests/inspector/inspected-objects-not-overriden.html
new file mode 100644
index 0000000..d5d1294
--- /dev/null
+++ b/LayoutTests/inspector/inspected-objects-not-overriden.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<script src="inspector-test.js"></script>
+<script>
+
+function myImpl() {
+  return "my value";
+}
+
+// Provide some custom methods.
+Object.type = myImpl;
+Object.hasProperties = myImpl;
+Object.describe = myImpl;
+Object.className = myImpl;
+String.prototype.escapeCharacters = myImpl;
+JSON.stringify = myImpl;
+
+function doit()
+{
+    function callback(result)
+    {
+        // Check that the methods haven't changed.
+        output("myImpl() => " + myImpl());
+        output("Object.type === myImpl => " + (Object.type === myImpl));
+        output("Object.hasProperties === myImpl => " + (Object.hasProperties === myImpl));
+        output("Object.describe === myImpl => " + (Object.describe === myImpl));
+        output("Object.className === myImpl => " + (Object.className === myImpl));
+        output("String.prototype.escapeCharacters === myImpl => " + (String.prototype.escapeCharacters === myImpl));
+        output("JSON.stringify === myImpl => " + (JSON.stringify === myImpl));
+
+        notifyDone();
+    }
+    evaluateInWebInspector("true", callback);
+}
+
+</script>
+</head>
+
+<body onload="onload()">
+<p>
+Tests that opening inspector front-end doesn't change methods defined by the inspected application.
+</p>
+
+<pre id="outputPre">
+</pre>
+
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index bef6c3b..bea78a0 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,16 @@
+2010-01-25  Yury Semikhatsky  <yurys at chromium.org>
+
+        Reviewed by Timothy Hatcher.
+
+        Instead of adding inspector methods to the inspected global objects
+        use private implementation visible from inspector code only.
+        https://bugs.webkit.org/show_bug.cgi?id=34089
+
+        Test: inspector/inspected-objects-not-overriden.html
+
+        * inspector/front-end/InjectedScript.js:
+        (injectedScriptConstructor):
+
 2010-01-25  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Timothy Hatcher.
diff --git a/WebCore/inspector/front-end/InjectedScript.js b/WebCore/inspector/front-end/InjectedScript.js
index f1ea5ed..0b34b9c 100644
--- a/WebCore/inspector/front-end/InjectedScript.js
+++ b/WebCore/inspector/front-end/InjectedScript.js
@@ -85,7 +85,7 @@ InjectedScript.reset();
 
 InjectedScript.dispatch = function(methodName, args, callId)
 {
-    var argsArray = JSON.parse(args);
+    var argsArray = InjectedScript.JSON.parse(args);
     if (callId)
         argsArray.splice(0, 0, callId);  // Methods that run asynchronously have a call back id parameter.
     var result = InjectedScript[methodName].apply(InjectedScript, argsArray);
@@ -476,7 +476,7 @@ InjectedScript.getPrototypes = function(nodeId)
 
     var result = [];
     for (var prototype = node; prototype; prototype = prototype.__proto__) {
-        var title = Object.describe(prototype, true);
+        var title = InjectedScript._describe(prototype, true);
         if (title.match(/Prototype$/)) {
             title = title.replace(/Prototype$/, "");
         }
@@ -544,7 +544,7 @@ InjectedScript.setPropertyValue = function(objectProxy, propertyName, expression
         return true;
     } catch(e) {
         try {
-            var result = InjectedScript._window().eval("\"" + expression.escapeCharacters("\"") + "\"");
+            var result = InjectedScript._window().eval("\"" + InjectedScript._escapeCharacters(expression, "\"") + "\"");
             object[propertyName] = result;
             return true;
         } catch(e) {
@@ -660,7 +660,7 @@ InjectedScript._evaluateOn = function(evalFunction, object, expression)
     var value = evalFunction.call(object, expression);
 
     // When evaluating on call frame error is not thrown, but returned as a value.
-    if (Object.type(value) === "error")
+    if (InjectedScript._type(value) === "error")
         throw value.toString();
 
     return value;
@@ -700,9 +700,9 @@ InjectedScript.performSearch = function(whitespaceTrimmedQuery)
     if (!/^[a-zA-Z0-9\-_:]+$/.test(attributeNameQuery))
         attributeNameQuery = null;
 
-    const escapedQuery = whitespaceTrimmedQuery.escapeCharacters("'");
-    const escapedTagNameQuery = (tagNameQuery ? tagNameQuery.escapeCharacters("'") : null);
-    const escapedWhitespaceTrimmedQuery = whitespaceTrimmedQuery.escapeCharacters("'");
+    const escapedQuery = InjectedScript._escapeCharacters(whitespaceTrimmedQuery, "'");
+    const escapedTagNameQuery = (tagNameQuery ?  InjectedScript._escapeCharacters(tagNameQuery, "'") : null);
+    const escapedWhitespaceTrimmedQuery = InjectedScript._escapeCharacters(whitespaceTrimmedQuery, "'");
     const searchResultsProperty = InjectedScript._includedInSearchResultsPropertyName;
 
     function addNodesToResults(nodes, length, getItem)
@@ -966,10 +966,10 @@ InjectedScript._inspectObject = function(o)
         return;
 
     inspectedWindow.console.log(o);
-    if (Object.type(o) === "node") {
+    if (InjectedScript._type(o) === "node") {
         InjectedScriptHost.pushNodePathToFrontend(o, false, true);
     } else {
-        switch (Object.describe(o)) {
+        switch (InjectedScript._describe(o)) {
             case "Database":
                 InjectedScriptHost.selectDatabase(o);
                 break;
@@ -982,7 +982,7 @@ InjectedScript._inspectObject = function(o)
 
 InjectedScript._copy = function(o)
 {
-    if (Object.type(o) === "node") {
+    if (InjectedScript._type(o) === "node") {
         var nodeId = InjectedScriptHost.pushNodePathToFrontend(o, false, false);
         InjectedScriptHost.copyNode(nodeId);
     } else {
@@ -1122,7 +1122,7 @@ InjectedScript._objectForId = function(objectId)
 InjectedScript.pushNodeToFrontend = function(objectProxy)
 {
     var object = InjectedScript._resolveObject(objectProxy);
-    if (!object || Object.type(object) !== "node")
+    if (!object || InjectedScript._type(object) !== "node")
         return false;
     return InjectedScriptHost.pushNodePathToFrontend(object, false, false);
 }
@@ -1140,7 +1140,7 @@ InjectedScript.createProxyObject = function(object, objectId, abbreviate)
     var result = {};
     result.injectedScriptId = injectedScriptId;
     result.objectId = objectId;
-    result.type = Object.type(object);
+    result.type = InjectedScript._type(object);
 
     var type = typeof object;
     if ((type === "object" && object !== null) || type === "function") {
@@ -1150,7 +1150,7 @@ InjectedScript.createProxyObject = function(object, objectId, abbreviate)
         }
     }
     try {
-        result.description = Object.describe(object, abbreviate);
+        result.description = InjectedScript._describe(object, abbreviate);
     } catch (e) {
         result.errorText = e.toString();
     }
@@ -1245,7 +1245,7 @@ InjectedScript._isDefined = function(object)
     return object || object instanceof inspectedWindow.HTMLAllCollection;
 }
 
-Object.type = function(obj)
+InjectedScript._type = function(obj)
 {
     if (obj === null)
         return "null";
@@ -1283,19 +1283,10 @@ Object.type = function(obj)
     return type;
 }
 
-Object.hasProperties = function(obj)
+InjectedScript._describe = function(obj, abbreviated)
 {
-    if (typeof obj === "undefined" || typeof obj === "null")
-        return false;
-    for (var name in obj)
-        return true;
-    return false;
-}
-
-Object.describe = function(obj, abbreviated)
-{
-    var type1 = Object.type(obj);
-    var type2 = Object.className(obj);
+    var type1 = InjectedScript._type(obj);
+    var type2 = InjectedScript._className(obj);
 
     switch (type1) {
     case "object":
@@ -1320,39 +1311,29 @@ Object.describe = function(obj, abbreviated)
     }
 }
 
-Object.className = function(obj)
+InjectedScript._className = function(obj)
 {
     return Object.prototype.toString.call(obj).replace(/^\[object (.*)\]$/i, "$1")
 }
 
-// Although Function.prototype.bind and String.prototype.escapeCharacters are defined in utilities.js they will soon become
-// unavailable in the InjectedScript context. So we define them here for the local use.
-// TODO: remove this comment once InjectedScript runs in a separate context.
-Function.prototype.bind = function(thisObject)
-{
-    var func = this;
-    var args = Array.prototype.slice.call(arguments, 1);
-    return function() { return func.apply(thisObject, args.concat(Array.prototype.slice.call(arguments, 0))) };
-}
-
-String.prototype.escapeCharacters = function(chars)
+InjectedScript._escapeCharacters = function(str, chars)
 {
     var foundChar = false;
     for (var i = 0; i < chars.length; ++i) {
-        if (this.indexOf(chars.charAt(i)) !== -1) {
+        if (str.indexOf(chars.charAt(i)) !== -1) {
             foundChar = true;
             break;
         }
     }
 
     if (!foundChar)
-        return this;
+        return str;
 
     var result = "";
-    for (var i = 0; i < this.length; ++i) {
-        if (chars.indexOf(this.charAt(i)) !== -1)
+    for (var i = 0; i < str.length; ++i) {
+        if (chars.indexOf(str.charAt(i)) !== -1)
             result += "\\";
-        result += this.charAt(i);
+        result += str.charAt(i);
     }
 
     return result;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list