Diff
Modified: trunk/LayoutTests/ChangeLog (143573 => 143574)
--- trunk/LayoutTests/ChangeLog 2013-02-21 09:04:02 UTC (rev 143573)
+++ trunk/LayoutTests/ChangeLog 2013-02-21 09:18:19 UTC (rev 143574)
@@ -1,3 +1,14 @@
+2013-02-21 Ken Kania <[email protected]>
+
+ Web Inspector: Add command for selecting files for file input element
+ https://bugs.webkit.org/show_bug.cgi?id=109308
+
+ Reviewed by Pavel Feldman.
+
+ * inspector-protocol/dom/setFileInputFiles-expected.txt: Added.
+ * inspector-protocol/dom/setFileInputFiles.html: Added.
+ * platform/chromium/inspector-protocol/dom/setFileInputFiles-expected.txt: Added.
+
2013-02-21 Pan Deng <[email protected]>
[Web Inspector]Add WebSocket networking events in WebInspector Timeline panel.
Added: trunk/LayoutTests/inspector-protocol/dom/setFileInputFiles-expected.txt (0 => 143574)
--- trunk/LayoutTests/inspector-protocol/dom/setFileInputFiles-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector-protocol/dom/setFileInputFiles-expected.txt 2013-02-21 09:18:19 UTC (rev 143574)
@@ -0,0 +1,4 @@
+
+Received error: Cannot set file input files
+Received error: Cannot set file input files
+
Added: trunk/LayoutTests/inspector-protocol/dom/setFileInputFiles.html (0 => 143574)
--- trunk/LayoutTests/inspector-protocol/dom/setFileInputFiles.html (rev 0)
+++ trunk/LayoutTests/inspector-protocol/dom/setFileInputFiles.html 2013-02-21 09:18:19 UTC (rev 143574)
@@ -0,0 +1,69 @@
+<html>
+<head>
+<script type="text/_javascript_" src=""
+<script>
+
+function onLoad()
+{
+ document.querySelector("input").addEventListener("change", onChange);
+
+ function onChange(event)
+ {
+ var files = event.target.files;
+ log("File count: " + files.length);
+ for (var i = 0; i < files.length; i++) {
+ log("Name: " + files[i].name);
+ }
+ }
+
+ runTest();
+}
+
+function test()
+{
+ function abortOnError(message)
+ {
+ if (message.error) {
+ InspectorTest.log(message.error.message);
+ InspectorTest.completeTest();
+ }
+ }
+
+ InspectorTest.sendCommand("DOM.getDocument", {}, onGotDocument);
+
+ function onGotDocument(message)
+ {
+ abortOnError(message);
+ var node = message.result.root;
+ InspectorTest.sendCommand("DOM.querySelectorAll", { "nodeId": node.nodeId, "selector": "input" }, onQuerySelectorAll);
+ }
+
+ function onQuerySelectorAll(message)
+ {
+ abortOnError(message);
+ var ids = message.result.nodeIds;
+ InspectorTest.sendCommand("DOM.setFileInputFiles", { "nodeId": ids[0], "files": ["file1", "file2"] }, onSetFiles);
+ InspectorTest.sendCommand("DOM.setFileInputFiles", { "nodeId": ids[1], "files": ["file1", "file2"] }, onBadSetFiles);
+ }
+
+ function onSetFiles(message)
+ {
+ if (message.error) {
+ InspectorTest.log("Received error: " + message.error.message);
+ }
+ }
+
+ function onBadSetFiles(message)
+ {
+ InspectorTest.log("Received error: " + message.error.message);
+ InspectorTest.completeTest();
+ }
+}
+
+</script>
+</head>
+<body _onload_="onLoad()">
+<input type="file"></input>
+<input type="text"></input>
+</body>
+</html>
Added: trunk/LayoutTests/platform/chromium/inspector-protocol/dom/setFileInputFiles-expected.txt (0 => 143574)
--- trunk/LayoutTests/platform/chromium/inspector-protocol/dom/setFileInputFiles-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/chromium/inspector-protocol/dom/setFileInputFiles-expected.txt 2013-02-21 09:18:19 UTC (rev 143574)
@@ -0,0 +1,6 @@
+
+File count: 2
+Name: file1
+Name: file2
+Received error: Node is not a file input element
+
Modified: trunk/Source/WebCore/ChangeLog (143573 => 143574)
--- trunk/Source/WebCore/ChangeLog 2013-02-21 09:04:02 UTC (rev 143573)
+++ trunk/Source/WebCore/ChangeLog 2013-02-21 09:18:19 UTC (rev 143574)
@@ -1,3 +1,27 @@
+2013-02-21 Ken Kania <[email protected]>
+
+ Web Inspector: Add command for selecting files for file input element
+ https://bugs.webkit.org/show_bug.cgi?id=109308
+
+ Reviewed by Pavel Feldman.
+
+ Test: inspector-protocol/dom/setFileInputFiles.html
+
+ * inspector/Inspector.json:
+ * inspector/InspectorClient.h:
+ (WebCore::InspectorClient::canSetFileInputFiles):
+ (InspectorClient):
+ * inspector/InspectorController.cpp:
+ (WebCore::InspectorController::InspectorController):
+ * inspector/InspectorDOMAgent.cpp:
+ (WebCore::InspectorDOMAgent::InspectorDOMAgent):
+ (WebCore::InspectorDOMAgent::setFileInputFiles):
+ (WebCore):
+ * inspector/InspectorDOMAgent.h:
+ (WebCore):
+ (WebCore::InspectorDOMAgent::create):
+ (InspectorDOMAgent):
+
2013-02-21 Pan Deng <[email protected]>
[Web Inspector]Add WebSocket networking events in Timeline panel.
Modified: trunk/Source/WebCore/inspector/Inspector.json (143573 => 143574)
--- trunk/Source/WebCore/inspector/Inspector.json 2013-02-21 09:04:02 UTC (rev 143573)
+++ trunk/Source/WebCore/inspector/Inspector.json 2013-02-21 09:18:19 UTC (rev 143574)
@@ -2063,10 +2063,19 @@
{
"name": "focus",
"parameters": [
- { "name": "nodeId", "$ref": "DOM.NodeId", "description": "Id of the node to focus." }
+ { "name": "nodeId", "$ref": "NodeId", "description": "Id of the node to focus." }
],
"description": "Focuses the given element.",
"hidden": true
+ },
+ {
+ "name": "setFileInputFiles",
+ "parameters": [
+ { "name": "nodeId", "$ref": "NodeId", "description": "Id of the file input node to set files for." },
+ { "name": "files", "type": "array", "items": { "type": "string" }, "description": "Array of file paths to set." }
+ ],
+ "description": "Sets files for the given file input element.",
+ "hidden": true
}
],
"events": [
Modified: trunk/Source/WebCore/inspector/InspectorClient.h (143573 => 143574)
--- trunk/Source/WebCore/inspector/InspectorClient.h 2013-02-21 09:04:02 UTC (rev 143573)
+++ trunk/Source/WebCore/inspector/InspectorClient.h 2013-02-21 09:18:19 UTC (rev 143574)
@@ -91,6 +91,8 @@
virtual bool handleJavaScriptDialog(bool) { return false; }
+ virtual bool canSetFileInputFiles() { return false; }
+
static bool doDispatchMessageOnFrontendPage(Page* frontendPage, const String& message);
};
Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (143573 => 143574)
--- trunk/Source/WebCore/inspector/InspectorController.cpp 2013-02-21 09:04:02 UTC (rev 143573)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp 2013-02-21 09:18:19 UTC (rev 143574)
@@ -98,7 +98,7 @@
m_pageAgent = pageAgentPtr.get();
m_agents.append(pageAgentPtr.release());
- OwnPtr<InspectorDOMAgent> domAgentPtr(InspectorDOMAgent::create(m_instrumentingAgents.get(), pageAgent, m_state.get(), m_injectedScriptManager.get(), m_overlay.get()));
+ OwnPtr<InspectorDOMAgent> domAgentPtr(InspectorDOMAgent::create(m_instrumentingAgents.get(), pageAgent, m_state.get(), m_injectedScriptManager.get(), m_overlay.get(), inspectorClient));
m_domAgent = domAgentPtr.get();
m_agents.append(domAgentPtr.release());
Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (143573 => 143574)
--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2013-02-21 09:04:02 UTC (rev 143573)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2013-02-21 09:18:19 UTC (rev 143574)
@@ -59,15 +59,19 @@
#include "EventListener.h"
#include "EventNames.h"
#include "EventTarget.h"
+#include "File.h"
+#include "FileList.h"
#include "Frame.h"
#include "FrameTree.h"
#include "HTMLElement.h"
#include "HTMLFrameOwnerElement.h"
+#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "HTMLTemplateElement.h"
#include "HitTestResult.h"
#include "IdentifiersFactory.h"
#include "InjectedScriptManager.h"
+#include "InspectorClient.h"
#include "InspectorFrontend.h"
#include "InspectorHistory.h"
#include "InspectorOverlay.h"
@@ -194,11 +198,12 @@
return "";
}
-InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorCompositeState* inspectorState, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay)
+InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorCompositeState* inspectorState, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay, InspectorClient* client)
: InspectorBaseAgent<InspectorDOMAgent>("DOM", instrumentingAgents, inspectorState)
, m_pageAgent(pageAgent)
, m_injectedScriptManager(injectedScriptManager)
, m_overlay(overlay)
+ , m_client(client)
, m_frontend(0)
, m_domListener(0)
, m_lastNodeId(1)
@@ -1200,6 +1205,34 @@
element->focus();
}
+void InspectorDOMAgent::setFileInputFiles(ErrorString* errorString, int nodeId, const RefPtr<InspectorArray>& files)
+{
+ if (!m_client->canSetFileInputFiles()) {
+ *errorString = "Cannot set file input files";
+ return;
+ }
+
+ Node* node = assertNode(errorString, nodeId);
+ if (!node)
+ return;
+ HTMLInputElement* element = node->toInputElement();
+ if (!element || !element->isFileUpload()) {
+ *errorString = "Node is not a file input element";
+ return;
+ }
+
+ RefPtr<FileList> fileList = FileList::create();
+ for (InspectorArray::const_iterator iter = files->begin(); iter != files->end(); ++iter) {
+ String path;
+ if (!(*iter)->asString(&path)) {
+ *errorString = "Files must be strings";
+ return;
+ }
+ fileList->append(File::create(path));
+ }
+ element->setFiles(fileList);
+}
+
void InspectorDOMAgent::resolveNode(ErrorString* errorString, int nodeId, const String* const objectGroup, RefPtr<TypeBuilder::Runtime::RemoteObject>& result)
{
String objectGroupName = objectGroup ? *objectGroup : "";
Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.h (143573 => 143574)
--- trunk/Source/WebCore/inspector/InspectorDOMAgent.h 2013-02-21 09:04:02 UTC (rev 143573)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.h 2013-02-21 09:18:19 UTC (rev 143574)
@@ -57,6 +57,7 @@
class Document;
class Element;
class Event;
+class InspectorClient;
class InspectorFrontend;
class InspectorHistory;
class InspectorOverlay;
@@ -102,9 +103,9 @@
virtual void didModifyDOMAttr(Element*) = 0;
};
- static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorCompositeState* inspectorState, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay)
+ static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorCompositeState* inspectorState, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay, InspectorClient* client)
{
- return adoptPtr(new InspectorDOMAgent(instrumentingAgents, pageAgent, inspectorState, injectedScriptManager, overlay));
+ return adoptPtr(new InspectorDOMAgent(instrumentingAgents, pageAgent, inspectorState, injectedScriptManager, overlay, client));
}
static String toErrorString(const ExceptionCode&);
@@ -149,6 +150,7 @@
virtual void redo(ErrorString*);
virtual void markUndoableState(ErrorString*);
virtual void focus(ErrorString*, int nodeId);
+ virtual void setFileInputFiles(ErrorString*, int nodeId, const RefPtr<InspectorArray>& files);
void getEventListeners(Node*, Vector<EventListenerInfo>& listenersArray, bool includeAncestors);
@@ -204,7 +206,7 @@
int pushNodePathForRenderLayerToFrontend(const RenderLayer*);
private:
- InspectorDOMAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorCompositeState*, InjectedScriptManager*, InspectorOverlay*);
+ InspectorDOMAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorCompositeState*, InjectedScriptManager*, InspectorOverlay*, InspectorClient*);
void setSearchingForNode(ErrorString*, bool enabled, InspectorObject* highlightConfig);
PassOwnPtr<HighlightConfig> highlightConfigFromInspectorObject(ErrorString*, InspectorObject* highlightInspectorObject);
@@ -236,6 +238,7 @@
InspectorPageAgent* m_pageAgent;
InjectedScriptManager* m_injectedScriptManager;
InspectorOverlay* m_overlay;
+ InspectorClient* m_client;
InspectorFrontend::DOM* m_frontend;
DOMListener* m_domListener;
NodeToIdMap m_documentNodeToIdMap;
Modified: trunk/Source/WebKit/chromium/ChangeLog (143573 => 143574)
--- trunk/Source/WebKit/chromium/ChangeLog 2013-02-21 09:04:02 UTC (rev 143573)
+++ trunk/Source/WebKit/chromium/ChangeLog 2013-02-21 09:18:19 UTC (rev 143574)
@@ -1,3 +1,16 @@
+2013-02-21 Ken Kania <[email protected]>
+
+ Web Inspector: Add command for selecting files for file input element
+ https://bugs.webkit.org/show_bug.cgi?id=109308
+
+ Reviewed by Pavel Feldman.
+
+ * src/InspectorClientImpl.cpp:
+ (WebKit::InspectorClientImpl::canSetFileInputFiles):
+ (WebKit):
+ * src/InspectorClientImpl.h:
+ (InspectorClientImpl):
+
2013-02-20 Paweł Hajdan, Jr. <[email protected]>
Add gyp option to switch ENABLE(SQL_DATABASE)
Modified: trunk/Source/WebKit/chromium/src/InspectorClientImpl.cpp (143573 => 143574)
--- trunk/Source/WebKit/chromium/src/InspectorClientImpl.cpp 2013-02-21 09:04:02 UTC (rev 143573)
+++ trunk/Source/WebKit/chromium/src/InspectorClientImpl.cpp 2013-02-21 09:18:19 UTC (rev 143574)
@@ -228,6 +228,11 @@
return false;
}
+bool InspectorClientImpl::canSetFileInputFiles()
+{
+ return true;
+}
+
WebDevToolsAgentImpl* InspectorClientImpl::devToolsAgent()
{
return static_cast<WebDevToolsAgentImpl*>(m_inspectedWebView->devToolsAgent());
Modified: trunk/Source/WebKit/chromium/src/InspectorClientImpl.h (143573 => 143574)
--- trunk/Source/WebKit/chromium/src/InspectorClientImpl.h 2013-02-21 09:04:02 UTC (rev 143573)
+++ trunk/Source/WebKit/chromium/src/InspectorClientImpl.h 2013-02-21 09:18:19 UTC (rev 143574)
@@ -94,6 +94,8 @@
virtual bool handleJavaScriptDialog(bool accept);
+ virtual bool canSetFileInputFiles();
+
private:
WebDevToolsAgentImpl* devToolsAgent();