I have the following problem when running dart2js
compiled version of my chrome extension:
Uncaught TypeError: undefined is not a function
when executing
context['chrome']['runtime']['onConnect'].callMethod('addListener', [(port) { ... }]);
I have created an example which possibly points to the cause:
background.dart
import 'dart:js';
void main() {
print("main(): context['chrome']['runtime']['onConnect'] (${context['chrome']['runtime']['onConnect'].runtimeType}): ${context['chrome']['runtime']['onConnect']}");
}
prints in Dartium:
main(): context['chrome']['runtime']['onConnect'] (JsObject): [object Object]
but in Chrome:
main(): context['chrome']['runtime']['onConnect'] (Event): Instance of 'Event'
Is it related to Difference between Dartium and dart2js when building chrome extensions (https://code.google.com/p/dart/issues/detail?id=17086)?
Could someone suggest how to register chrome.runtime.onConnect
listener which would work in both Dartium and Chrome?