1
+ <!doctype html>
2
+ <!--
3
+ @license
4
+ Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
5
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8
+ Code distributed by Google as part of the polymer project is also
9
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10
+ -->
11
+ < html >
12
+
13
+ < head >
14
+ < title > HTML Imports es module</ title >
15
+ < script src ="../../src/html-imports.js "> </ script >
16
+ < script >
17
+ WCT = {
18
+ waitFor : function ( callback ) {
19
+ HTMLImports . whenReady ( callback ) ;
20
+ }
21
+ } ;
22
+ window . loadedModules = [ ] ;
23
+ </ script >
24
+ < script src ="../../../web-component-tester/browser.js "> </ script >
25
+ < link rel ="import " href ="./imports/es-module-import-1.html ">
26
+ </ head >
27
+
28
+ < body >
29
+
30
+ < script >
31
+ // Polymer build transpiles modules to AMD on browsers without es module and import.meta.url
32
+ // support. We should not execute this test in that case.
33
+ test ( 'es modules' , ( ) => {
34
+ if ( ! window . define ) {
35
+ assert . deepEqual ( window . loadedModules , [ 'es-module-2' , 'es-module-1' , 'es-module-3' ] ) ;
36
+ }
37
+ } ) ;
38
+
39
+ test ( 'inline module' , ( done ) => {
40
+ // This test should be executed only on browsers that support native modules but not HTML Imports
41
+ if ( ! window . define && ! HTMLImports . useNative ) {
42
+ const link = document . createElement ( 'link' ) ;
43
+ link . setAttribute ( 'rel' , 'import' ) ;
44
+ link . setAttribute ( 'href' , './imports/es-module-inline.html' ) ;
45
+
46
+ // Catch error thrown by polyfill
47
+ window . onerror = ( ) => {
48
+ done ( ) ;
49
+ }
50
+
51
+ document . head . appendChild ( link ) ;
52
+ } else {
53
+ done ( ) ;
54
+ }
55
+ } ) ;
56
+ </ script >
57
+ </ body >
58
+
59
+ </ html >
0 commit comments