librelist archives

« back to archive

Adding to Array.prototype is disastrous

Adding to Array.prototype is disastrous

Sean McAfee
2015-08-12 @ 18:15
This sure seems like a bug, but maybe I just don't know enough about
xulrunner, so I thought I'd check here first.

It seems that adding anything to Array.protoype renders Conkeror
permanently unable to accept keyboard input.  In a freshly-run instance of
Conkeror, with no .conkerorrc, if you evaluate the string
" = function () { return 1 }", Conkeror prints to the

NS_ERROR_FILE_NOT_FOUND: File error: Not found
> null()@chrome://conkeror/content/commands.js:283
> _co_impl__send()@chrome://conkeror/content/coroutine.js:415
> null()@resource://gre/modules/Promise.jsm:500
> null()@resource://gre/modules/Promise.jsm:282
> null()@null:0

Thereafter, all keypresses are ignored, each one generating on the console
a message like this:

NS_ERROR_FILE_NOT_FOUND: File error: Not found
> format_key_combo()@chrome://conkeror/content/keymap.js:96
> input_handle_sequence()@chrome://conkeror/content/input.js:201
> _co_impl__send()@chrome://conkeror/content/coroutine.js:415
> co_call()@chrome://conkeror/content/coroutine.js:561
> input_handle_keypress()@chrome://conkeror/content/input.js:303
> null()@null:0

If I instead put the prototype code directly into my init file, then run
Conkeror and press M-x, I get:

TypeError: modifiers[M] is undefined
> chrome://conkeror/content/keymap.js:96
> format_key_combo@chrome://conkeror/content/keymap.js:96
> input_handle_sequence@chrome://conkeror/content/input.js:201
> _co_impl__send@chrome://conkeror/content/coroutine.js:415
> co_call@chrome://conkeror/content/coroutine.js:561
> input_handle_keypress@chrome://conkeror/content/input.js:303
> Console error: [JavaScript Warning: "ReferenceError: reference to
> undefined property modifiers[M]" {file:
> "chrome://conkeror/content/keymap.js" line: 96}]

This reported bug covers some of the same ground:

So I tried evaluating " = function () { return 1 }; 1"
(note the "; 1" at the end).  This eliminated the first console message I
mentioned above, but subsequent keypresses still generated the second
message and were ignored.

This is with the most recent Conkeror sources and Xulrunner binary.  The
same thing happens if you add to Object.prototype as well.

The only reason I think this might conceivably not be a bug is that
Array.prototype seems to be a pretty strange beast in Conkeror.
typeof(Array.prototype) is "object", and Array.prototype.reduce (say) is a
function, but [ x for (x in Array.prototype) ].join(":") evaluates to the
empty string.  Maybe adding to prototype has to be done differently for
some reason?

Anyway, any guidance would be appreciated.