Index: client/dom/templates/html/frog/html_frog.darttemplate |
diff --git a/client/dom/templates/html/frog/html_frog.darttemplate b/client/dom/templates/html/frog/html_frog.darttemplate |
index 65bafde89a17b5177d86bb12261cf0b509413c77..80aa6b287ccd27ca0388f92f0eb6234825c3c683 100644 |
--- a/client/dom/templates/html/frog/html_frog.darttemplate |
+++ b/client/dom/templates/html/frog/html_frog.darttemplate |
@@ -15,15 +15,50 @@ $!GENERATED_DART_FILES |
#source('../dom/src/ReadyState.dart'); |
#source('../dom/src/TimeoutHandler.dart'); |
#source('../dom/src/_Collections.dart'); |
+#source('../html/src/Measurement.dart'); |
+#source('../html/src/shared_FactoryProviders.dart'); |
#source('../html/src/frog_FactoryProviders.dart'); |
+#source('../html/src/_Testing.dart'); |
#source('../html/src/Device.dart'); |
#source('../dom/src/_ListIterators.dart'); |
#source('../dom/src/_Lists.dart'); |
-// TODO(sra): What 'window' do we get in a worker? Perhaps this |
-// should return the interface type. |
-Window get window() native "return window;"; |
-_WindowJs get _window() native "return window;"; |
+_WindowImpl _cachedWindow; |
+_DocumentImpl _cachedDocument; |
-Document get document() native "return window.document.documentElement;"; |
-_DocumentJs get _document() native "return window.document.documentElement;"; |
+void _init() { |
+ _cachedDocument = _document; |
+ _cachedWindow = _window; |
+ // Feature detect that dart:dom and dart:html are not both loaded by |
+ // checking for the presence of a bug that manifests itself when both |
+ // libraries are loaded. |
+ // TODO(jacobr): remove this code once b/1911 is fixed and the frog compiler |
+ // is changed to generate compile time errors if two libraries that define |
+ // the same native types in conflicting ways are imported. |
+ var element = new Element.tag('body'); |
+ element.innerHTML = 'f'; |
+ if (element.text == '') { |
+ _cachedWindow.console.error( |
+ 'Cannot import dart:html and dart:dom within the same application.'); |
+ throw new UnsupportedOperationException( |
+ 'Cannot import dart:html and dart:dom within the same application.'); |
+ } |
+} |
+ |
+Window get window() { |
+ if (_cachedWindow == null) { |
+ _init(); |
+ } |
+ return _cachedWindow; |
+} |
+ |
+_WindowImpl get _window() native "return window;"; |
+ |
+Document get document() { |
+ if (_cachedDocument == null) { |
+ _init(); |
+ } |
+ return _cachedDocument; |
+} |
+ |
+_DocumentImpl get _document() native "return window.document.documentElement;"; |