Diff
Modified: trunk/Source/WebCore/ChangeLog (144915 => 144916)
--- trunk/Source/WebCore/ChangeLog 2013-03-06 14:06:40 UTC (rev 144915)
+++ trunk/Source/WebCore/ChangeLog 2013-03-06 14:07:36 UTC (rev 144916)
@@ -1,3 +1,28 @@
+2013-03-06 Yury Semikhatsky <yu...@chromium.org>
+
+ Web Inspector: use regular eval instead of injectScript for front-end extension API
+ https://bugs.webkit.org/show_bug.cgi?id=111529
+
+ Reviewed by Pavel Feldman.
+
+ Removed InjectedScriptManager::injectScript and replaced all of it calls
+ except the actual script injection with ScriptController::executeScript.
+
+ * inspector/InjectedScriptManager.cpp:
+ (WebCore::InjectedScriptManager::injectedScriptFor):
+ * inspector/InjectedScriptManager.h:
+ (InjectedScriptManager):
+ * inspector/InspectorAgent.cpp:
+ (WebCore::InspectorAgent::didClearWindowObjectInWorld):
+ * inspector/InspectorPageAgent.cpp:
+ (WebCore::InspectorPageAgent::didClearWindowObjectInWorld):
+ * inspector/front-end/DOMAgent.js:
+ (WebInspector.DOMAgent.prototype._emulateTouchEventsChanged.get if):
+ * inspector/front-end/ExtensionAPI.js:
+ (buildExtensionAPIInjectedScript):
+ * inspector/front-end/ExtensionServer.js:
+ (WebInspector.ExtensionServer.prototype._onReload):
+
2013-03-06 Allan Sandfeld Jensen <allan.jen...@digia.com>
[Qt] Do not disable C++0x
Modified: trunk/Source/WebCore/inspector/InjectedScriptManager.cpp (144915 => 144916)
--- trunk/Source/WebCore/inspector/InjectedScriptManager.cpp 2013-03-06 14:06:40 UTC (rev 144915)
+++ trunk/Source/WebCore/inspector/InjectedScriptManager.cpp 2013-03-06 14:07:36 UTC (rev 144916)
@@ -40,10 +40,7 @@
#include "InspectorValues.h"
#include "ScriptObject.h"
#include <wtf/PassOwnPtr.h>
-#include <wtf/StdLibExtras.h>
-using namespace std;
-
namespace WebCore {
PassOwnPtr<InjectedScriptManager> InjectedScriptManager::createForPage()
@@ -163,12 +160,6 @@
return String(reinterpret_cast<const char*>(InjectedScriptSource_js), sizeof(InjectedScriptSource_js));
}
-pair<int, ScriptObject> InjectedScriptManager::injectScript(const String& source, ScriptState* scriptState)
-{
- int id = injectedScriptIdFor(scriptState);
- return std::make_pair(id, createInjectedScript(source, scriptState, id));
-}
-
InjectedScript InjectedScriptManager::injectedScriptFor(ScriptState* inspectedScriptState)
{
ScriptStateToId::iterator it = m_scriptStateToId.find(inspectedScriptState);
@@ -181,9 +172,10 @@
if (!m_inspectedStateAccessCheck(inspectedScriptState))
return InjectedScript();
- pair<int, ScriptObject> injectedScript = injectScript(injectedScriptSource(), inspectedScriptState);
- InjectedScript result(injectedScript.second, m_inspectedStateAccessCheck);
- m_idToInjectedScript.set(injectedScript.first, result);
+ int id = injectedScriptIdFor(inspectedScriptState);
+ ScriptObject injectedScriptObject = createInjectedScript(injectedScriptSource(), inspectedScriptState, id);
+ InjectedScript result(injectedScriptObject, m_inspectedStateAccessCheck);
+ m_idToInjectedScript.set(id, result);
return result;
}
Modified: trunk/Source/WebCore/inspector/InjectedScriptManager.h (144915 => 144916)
--- trunk/Source/WebCore/inspector/InjectedScriptManager.h 2013-03-06 14:06:40 UTC (rev 144915)
+++ trunk/Source/WebCore/inspector/InjectedScriptManager.h 2013-03-06 14:07:36 UTC (rev 144916)
@@ -54,7 +54,6 @@
InjectedScriptHost* injectedScriptHost();
- pair<int, ScriptObject> injectScript(const String& source, ScriptState*);
InjectedScript injectedScriptFor(ScriptState*);
InjectedScript injectedScriptForId(int);
int injectedScriptIdFor(ScriptState*);
Modified: trunk/Source/WebCore/inspector/InspectorAgent.cpp (144915 => 144916)
--- trunk/Source/WebCore/inspector/InspectorAgent.cpp 2013-03-06 14:06:40 UTC (rev 144915)
+++ trunk/Source/WebCore/inspector/InspectorAgent.cpp 2013-03-06 14:07:36 UTC (rev 144916)
@@ -88,8 +88,15 @@
String origin = frame->document()->securityOrigin()->toRawString();
String script = m_injectedScriptForOrigin.get(origin);
- if (!script.isEmpty())
- m_injectedScriptManager->injectScript(script, mainWorldScriptState(frame));
+ if (script.isEmpty())
+ return;
+ int injectedScriptId = m_injectedScriptManager->injectedScriptIdFor(mainWorldScriptState(frame));
+ StringBuilder scriptSource;
+ scriptSource.append(script);
+ scriptSource.append("(");
+ scriptSource.appendNumber(injectedScriptId);
+ scriptSource.append(")");
+ frame->script()->executeScript(scriptSource.toString());
}
void InspectorAgent::setFrontend(InspectorFrontend* inspectorFrontend)
Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (144915 => 144916)
--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2013-03-06 14:06:40 UTC (rev 144915)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2013-03-06 14:07:36 UTC (rev 144916)
@@ -852,11 +852,11 @@
for (InspectorObject::const_iterator it = scripts->begin(); it != end; ++it) {
String scriptText;
if (it->value->asString(&scriptText))
- m_injectedScriptManager->injectScript(scriptText, mainWorldScriptState(frame));
+ frame->script()->executeScript(scriptText);
}
}
if (!m_scriptToEvaluateOnLoadOnce.isEmpty())
- m_injectedScriptManager->injectScript(m_scriptToEvaluateOnLoadOnce, mainWorldScriptState(frame));
+ frame->script()->executeScript(m_scriptToEvaluateOnLoadOnce);
}
void InspectorPageAgent::domContentEventFired()
Modified: trunk/Source/WebCore/inspector/front-end/DOMAgent.js (144915 => 144916)
--- trunk/Source/WebCore/inspector/front-end/DOMAgent.js 2013-03-06 14:06:40 UTC (rev 144915)
+++ trunk/Source/WebCore/inspector/front-end/DOMAgent.js 2013-03-06 14:07:36 UTC (rev 144916)
@@ -1322,7 +1322,7 @@
var emulationEnabled = WebInspector.settings.emulateTouchEvents.get();
if (emulationEnabled && !this._addTouchEventsScriptInjecting) {
this._addTouchEventsScriptInjecting = true;
- PageAgent.addScriptToEvaluateOnLoad("(" + injectedFunction.toString() + ")", scriptAddedCallback.bind(this));
+ PageAgent.addScriptToEvaluateOnLoad("(" + injectedFunction.toString() + ")()", scriptAddedCallback.bind(this));
} else {
if (typeof this._addTouchEventsScriptId !== "undefined") {
PageAgent.removeScriptToEvaluateOnLoad(this._addTouchEventsScriptId);
Modified: trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js (144915 => 144916)
--- trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js 2013-03-06 14:06:40 UTC (rev 144915)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js 2013-03-06 14:07:36 UTC (rev 144916)
@@ -885,7 +885,7 @@
function buildExtensionAPIInjectedScript(extensionInfo)
{
- return "(function(injectedScriptHost, inspectedWindow, injectedScriptId){ " +
+ return "(function(injectedScriptId){ " +
"var extensionServer;" +
defineCommonExtensionSymbols.toString() + ";" +
injectedExtensionAPI.toString() + ";" +
Modified: trunk/Source/WebCore/inspector/front-end/ExtensionServer.js (144915 => 144916)
--- trunk/Source/WebCore/inspector/front-end/ExtensionServer.js 2013-03-06 14:06:40 UTC (rev 144915)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionServer.js 2013-03-06 14:07:36 UTC (rev 144916)
@@ -310,11 +310,8 @@
var options = /** @type ExtensionReloadOptions */ (message.options || {});
NetworkAgent.setUserAgentOverride(typeof options.userAgent === "string" ? options.userAgent : "");
var injectedScript;
- if (options.injectedScript) {
- // Wrap client script into anonymous function, return another anonymous function that
- // returns empty object for compatibility with InjectedScriptManager on the backend.
- injectedScript = "((function(){" + options.injectedScript + "})(),function(){return {}})";
- }
+ if (options.injectedScript)
+ injectedScript = "(function(){" + options.injectedScript + "})()";
PageAgent.reload(!!options.ignoreCache, injectedScript);
return this._status.OK();
},