You are not logged in.
I'm trying to add a javascript eventlistener to the bbs, for some reason this works fine in Firefox but not in Chromium. I did some additional testing and am getting strange results. Here's the test:
document.body.addEventListener('keydown', function() { console.log('1'); }, false);
[Firefox: OK] https://bbs.archlinux.org
[Firefox: OK] http://slashdot.org
[Firefox: OK] https://www.paypal.com
[Chromium: FAIL] https://bbs.archlinux.org
[Chromium: OK] http://slashdot.org
[Chromium: OK] https://www.paypal.com
FAIL means that the event didn't attach and/or fire.
The results were confirmed by another tester, but does anyone have any idea what could cause this?
It could be a Chromium bug, but i really wonder why only the bbs is affected...
Last edited by litemotiv (2012-11-28 22:30:31)
ᶘ ᵒᴥᵒᶅ
Offline
I think it has something to do with
application/xhtml+xml
After I tried to use an almost empty local html file to test, the event fired, I noticed the return MIME type from server, so I tried to find another page to test and found this page, the server returns the same MIME not text/html. And the event will not fire, either. I do not actually read the page, but one line caught my eyes:
document.body deprecated in favour of document.documentElement
Not sure if it has something to do with this issue. Strangely, if you use mouse event, e.g. click, the event will fire.
I've tried to attach the event on `document` and `document.documentElement` the keyboard event will fire.
Last edited by livibetter (2012-11-28 21:54:12)
Offline
Excellent detective work livibetter, that's definitely the cause.
ᶘ ᵒᴥᵒᶅ
Offline
Just curious, are you working on some user script or something new feature would be on forums?
Last edited by livibetter (2012-11-28 22:16:05)
Offline
No actually i was debugging the Type-ahead-find Chromium extension which stopped working on the Arch bbs. Nothing really exciting i'm afraid...
ᶘ ᵒᴥᵒᶅ
Offline
I was wondering why some of Vimprobable's keyboard functions had stopped working on the bbs (most annoyingly, the ability to open a text field in Vim); this seems to be the reason.
#edit: litemotiv, have you filed a bug report?
Offline
I was wondering why some of Vimprobable's keyboard functions had stopped working on the bbs (most annoyingly, the ability to open a text field in Vim); this seems to be the reason.
#edit: litemotiv, have you filed a bug report?
I did file a bugreport for Type-ahead-find, since technically this is a client bug.
XHTML is only parsed as a real XML document when the MIME type is set to application/xhtml+xml by the server. When that is the case, you run into the situation that document.body is not officially supported in XML, in favor of document.documentElement. So when using documentElement (or as livibetter found out possibly just 'document') instead, everything works as intended.
I copied an Arch bbs page to another server and the script worked fine there. probably because the other server didn't set the correct MIME and sent it as regular text/html. As such it wasn't a proper XML document and document.body was faux-supported.
Maybe XHTML got enforced more strictly recently in a Webkit update, that would explain why it used to work in both Chromium and other derivates like Vimprobable. If the latter relies on the same deprecated method of event attachment, then it should be reported as a bug there.
ᶘ ᵒᴥᵒᶅ
Offline
Maybe XHTML got enforced more strictly recently in a Webkit update, that would explain why it used to work in both Chromium and other derivates like Vimprobable. If the latter relies on the same deprecated method of event attachment, then it should be reported as a bug there.
That makes sense: thanks lite!
Offline