WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
83688
File API does not support DOM events (like addEventListener)
https://bugs.webkit.org/show_bug.cgi?id=83688
Summary
File API does not support DOM events (like addEventListener)
pimvdb
Reported
2012-04-11 05:58:30 PDT
The specifications of e.g. FileReader and FileWriter require that events are handled in the manner of DOM events. See:
http://www.w3.org/TR/FileAPI/#fire-a-progress-event
http://dev.w3.org/2009/dap/file-system/file-writer.html#dfn-fire-a-progress-event
Currently it's not possible to actually use functions such as addEventListener on file readers or file writers. It's merely possible to assign a function like: someFileWriter.onwriteend = func; It should be possible to do the following as well: someFileWriter.addEventListener("writeend", func, false);
Attachments
Test case
(749 bytes, text/html)
2012-04-11 13:50 PDT
,
pimvdb
no flags
Details
Patch
(6.08 KB, patch)
2012-04-11 16:04 PDT
,
Erik Arvidsson
abarth
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Alexey Proskuryakov
Comment 1
2012-04-11 13:34:45 PDT
Could you please attach a test case? This is known to work in WebKit - we even have a regression test verifying that: <
http://trac.webkit.org/browser/trunk/LayoutTests/fast/files/file-reader-event-listener.html
>.
pimvdb
Comment 2
2012-04-11 13:50:59 PDT
Created
attachment 136745
[details]
Test case I've attached a test case. I can reproduce on Google Chrome 20.0.1097.0 canary.
Alexey Proskuryakov
Comment 3
2012-04-11 14:37:10 PDT
The test is about FileSystem and FireWriter, maybe these are different somehow.
Alexey Proskuryakov
Comment 4
2012-04-11 14:40:36 PDT
FileWriter.idl has EventTarget attribute though, and had it for a very long time, so it's unclear what's going on.
Jian Li
Comment 5
2012-04-11 14:47:49 PDT
I think we need to expose EventTarget interface methods in FileWriter.idl, like what I did for FileReader:
http://trac.webkit.org/changeset/104180/trunk/Source/WebCore/fileapi/FileReader.idl
Erik Arvidsson
Comment 6
2012-04-11 15:06:07 PDT
It is not enough to include EventTarget as an extended attribute in the interface section. We also have to include the methods from the EventTarget interface. For example, look at Node.idl and XMLHttpRequest.idl. They both include addEventListener, removeEventListener and dispatchEvent. Here are the IDL files that are missing the implementation.
http://code.google.com/p/chromium/source/search?q=file%3A%5C.idl+%5CbEventTarget%28%2C%7C%5Cn%29+-addEventListener&origq=file%3A%5C.idl+%5CbEventTarget%28%2C%7C%5Cn%29+-addEventListener&btnG=Search+Trunk
The short fix is to add these 3 methods to the 3 incomplete idl files above. The long term, better solution is to implicitly add these method when we have an EventTarget.
Erik Arvidsson
Comment 7
2012-04-11 15:34:44 PDT
(In reply to
comment #6
)
> It is not enough to include EventTarget as an extended attribute in the interface section. We also have to include the methods from the EventTarget interface. > > For example, look at Node.idl and XMLHttpRequest.idl. They both include addEventListener, removeEventListener and dispatchEvent. > > Here are the IDL files that are missing the implementation. > >
http://code.google.com/p/chromium/source/search?q=file%3A%5C.idl+%5CbEventTarget%28%2C%7C%5Cn%29+-addEventListener&origq=file%3A%5C.idl+%5CbEventTarget%28%2C%7C%5Cn%29+-addEventListener&btnG=Search+Trunk
> > The short fix is to add these 3 methods to the 3 incomplete idl files above. The long term, better solution is to implicitly add these method when we have an EventTarget.
Sorry, the long term solution is to follow the spec and make interfaces extend the EventTarget interface instead of implementing it.
Erik Arvidsson
Comment 8
2012-04-11 15:53:11 PDT
The long term fix is covered by
bug 67312
. Short term fix coming in a minute.
Erik Arvidsson
Comment 9
2012-04-11 16:04:12 PDT
Created
attachment 136773
[details]
Patch
WebKit Review Bot
Comment 10
2012-04-11 16:09:43 PDT
Attachment 136773
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/fast..." exit_code: 1 Source/WebCore/ChangeLog:10: You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible. [changelog/nonewtests] [5] Total errors found: 1 in 7 files If any of these errors are false positives, please file a bug against check-webkit-style.
Adam Barth
Comment 11
2012-04-11 16:12:20 PDT
Comment on
attachment 136773
[details]
Patch Please fixenate the stylebot's complaint before landing.
Erik Arvidsson
Comment 12
2012-04-11 16:31:27 PDT
Committed
r113924
: <
http://trac.webkit.org/changeset/113924
>
Alexey Proskuryakov
Comment 13
2012-04-11 17:34:08 PDT
Comment on
attachment 136773
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=136773&action=review
> Source/WebCore/ChangeLog:3 > + File API does not support DOM events (like addEventListener)
In the future, please take care to rename a bug and update title in patch when scope of an issue becomes more clear. Here, we didn't have an issue with FileReader, but the fix changes a number of non-File APIs.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug