Kotlin2Js WebExtension Error


I tried to make a WebExtension for Firefox following this tutorial: https://medium.com/@Cypressious/your-first-firefox-web-extension-in-kotlin-348fc907915

My problem occurs when I try to iterate over ArrayLists of org.w3c.dom.Element, for Example

    .forEach { console.info(it) }

crashes with TypeError: throwCCE is not a function at

ArrayList.prototype.get_za3lpa$ = function (index) {
      var tmp$;
      return (tmp$ = this.array_hd7ov6$_0[this.rangeCheck_xcmk5o$_0(index)]) == null || Kotlin.isType(tmp$, Any) ? tmp$ : throwCCE();

I also don’t know why throwCCE is not defined at this point but i think the actual problem lies in the Koltin.isType function, as

console.info(js("Kotlin.isType(document.getElementsByTagName(\"div\")[0], Object)"))

prints false which would explain the error (I think Object in this context is the same as Any in the previous snippet?)

I created a project to reproduce the error here: https://bitbucket.org/KaiDev/webexttest/overview

Hope someone can help me :slight_smile:


The problem with throwCCE is not a function sounds like as an issue in DCE. Could you please check it w/o DCE and file an issue.


Which version of browser do you use? How do you run the code, as extesnsion?
Could you please check that this prints for you?

For me it prints:

Hello, world!
[object HTMLDivElement]
[object HTMLDivElement]