mirror of https://github.com/vitalif/phantomjs
commit
cec3fdd8a0
|
@ -72,6 +72,15 @@ public:
|
|||
setForwardUnsupportedContent(true);
|
||||
}
|
||||
|
||||
bool extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output) {
|
||||
if (extension == ChooseMultipleFilesExtension) {
|
||||
static_cast<ChooseMultipleFilesExtensionReturn*>(output)->fileNames = QStringList(m_uploadFile);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public slots:
|
||||
bool shouldInterruptJavaScript() {
|
||||
QApplication::processEvents(QEventLoop::AllEvents, 42);
|
||||
|
@ -80,6 +89,10 @@ public slots:
|
|||
|
||||
protected:
|
||||
|
||||
bool supportsExtension(Extension extension) const {
|
||||
return extension == ChooseMultipleFilesExtension;
|
||||
}
|
||||
|
||||
QString chooseFile(QWebFrame *originatingFrame, const QString &oldFile) {
|
||||
Q_UNUSED(originatingFrame);
|
||||
Q_UNUSED(oldFile);
|
||||
|
|
|
@ -206,17 +206,26 @@ describe("WebPage object", function() {
|
|||
|
||||
it("should handle file uploads", function() {
|
||||
runs(function() {
|
||||
page.content = '<input type="file" id="file">';
|
||||
page.content = '<input type="file" id="file">\n' +
|
||||
'<input type="file" id="file2" multiple>';
|
||||
page.uploadFile("#file", 'README.md');
|
||||
page.uploadFile("#file2", 'README.md');
|
||||
});
|
||||
|
||||
waits(50);
|
||||
|
||||
runs(function() {
|
||||
var fileName = page.evaluate(function() {
|
||||
var fileName;
|
||||
|
||||
fileName = page.evaluate(function() {
|
||||
return document.getElementById('file').files[0].fileName;
|
||||
});
|
||||
expect(fileName).toEqual('README.md');
|
||||
|
||||
fileName = page.evaluate(function() {
|
||||
return document.getElementById('file2').files[0].fileName;
|
||||
});
|
||||
expect(fileName).toEqual('README.md');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue