aboutsummaryrefslogtreecommitdiff
path: root/thirdparty/systemjs/test/test-csp.html
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/systemjs/test/test-csp.html')
-rw-r--r--thirdparty/systemjs/test/test-csp.html280
1 files changed, 280 insertions, 0 deletions
diff --git a/thirdparty/systemjs/test/test-csp.html b/thirdparty/systemjs/test/test-csp.html
new file mode 100644
index 000000000..f488974f6
--- /dev/null
+++ b/thirdparty/systemjs/test/test-csp.html
@@ -0,0 +1,280 @@
+<!doctype html>
+<html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/>
+ </head>
+ <body>
+
+ <h1 id="qunit-header">SystemJS Test Suite</h1>
+
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ <div id="qunit-test-area"></div>
+
+ <script src="../dist/system-csp-production.src.js" type="text/javascript"></script>
+ <script src="../bower_components/qunit/qunit/qunit.js"></script>
+
+ <script>
+ QUnit.config.testTimeout = 2000;
+
+ QUnit.module("SystemJS CSP");
+
+ function err(e) {
+ setTimeout(function() {
+ throw e.stack || e;
+ start();
+ });
+ }
+
+ asyncTest('System version', function() {
+ ok(System.version.match(/^\d+\.\d+\.\d+(-\w+)? CSP$/));
+ start();
+ });
+
+ asyncTest('Loading an AMD module', function() {
+ System['import']('tests/amd-module.js').then(function(m) {
+ ok(m.amd == true);
+ ok(m.dep.amd == 'dep');
+ start();
+ }, err);
+ });
+
+ System.config({
+ bundles: {
+ 'tests/amd-bundle.js': ['bundle-1', 'bundle-2']
+ }
+ });
+ asyncTest('Loading an AMD bundle', function() {
+ System['import']('bundle-1').then(function(m) {
+ ok(m.defined == true);
+ start();
+ }, err);
+
+ stop();
+ System['import']('bundle-2').then(function(m) {
+ ok(m.defined == true);
+ start();
+ }, err);
+ });
+
+ asyncTest('Loading an AMD named define', function() {
+ System['import']('tests/nameddefine.js').then(function() {
+ System['import']('another-define').then(function(m) {
+ ok(m.named == 'define');
+ start();
+ }, err);
+ }, err);
+ });
+
+ asyncTest('Global script with exports as an array', function() {
+ System.config({
+ meta: {
+ 'tests/global-exports-array.js': {
+ exports: ['A', 'B']
+ }
+ }
+ });
+
+ System['import']('tests/global-exports-array.js').then(function(m) {
+ ok(m.A == 'A');
+ ok(m.B == 'B');
+ ok(!m.C);
+ ok(m['default'] == 'A');
+ start();
+ }, err);
+ });
+
+ asyncTest('Loading a badly named AMD define', function() {
+ System['import']('tests/jquery-named.js').then(function(jquery) {
+ ok(jquery.is == 'jquery');
+ start();
+ }, err);
+ });
+
+
+ asyncTest('System.register Circular', function() {
+ System['import']('tests/register-circular1.js').then(function(m) {
+ ok(m.q == 3, 'Binding not allocated');
+ ok(m.r == 5, 'Binding not updated');
+ start();
+ }, err);
+ });
+
+
+ asyncTest('Loading a UMD module', function() {
+ System['import']('tests/umd.js').then(function(m) {
+ ok(m.d == 'hi');
+ start();
+ }, err);
+ });
+
+ asyncTest('Loading a bundle', function() {
+ System['import']('tests/bundle.js').then(function(m) {
+ return System['import']('bundle-define1');
+ })
+ .then(function(m) {
+ ok(m.name == 'bundle1');
+
+ return System['import']('bundle-define2');
+ })
+ .then(function(m) {
+ ok(m.name == 'bundle2');
+
+ start();
+ })
+ ['catch'](err);
+ });
+
+ asyncTest('Loading a bundle on demand', function() {
+
+ System.config({
+ bundles: {
+ 'tests/main-bundle.js': ['jquery']
+ }
+ });
+ System['import']('jquery').then(function(m) {
+ ok(m.name == 'jquery-bundled');
+ start();
+ }, err);
+ });
+
+ System.config({
+ bundles: {
+ 'tests/mixed-bundle.js': ['tree/third', 'tree/cjs', 'tree/jquery', 'tree/second', 'tree/global', 'tree/amd', 'tree/first']
+ }
+ });
+ asyncTest('Loading AMD from a bundle', function() {
+ System['import']('tree/amd').then(function(m) {
+ ok(m.is == 'amd');
+ start();
+ }, err);
+ });
+
+ asyncTest('Loading CommonJS from a bundle', function() {
+ System['import']('tree/cjs').then(function(m) {
+ ok(m.cjs === true);
+ start();
+ }, err);
+ });
+
+ asyncTest('Loading a Global from a bundle', function() {
+ System['import']('tree/global').then(function(m) {
+ ok(m === 'output');
+ start();
+ }, err);
+ });
+
+ asyncTest('Loading named System.register', function() {
+ System['import']('tree/third').then(function(m) {
+ ok(m.some == 'exports');
+ start();
+ }, err);
+ });
+
+ asyncTest('Loading System.register from ES6', function() {
+ System['import']('tree/first').then(function(m) {
+ ok(m.p == 5);
+ start();
+ });
+ });
+
+ asyncTest('Running a simple non-fetch plugin', function() {
+ System.set('tests/es6-plugin', System.newModule({
+ fetch: function() {
+ return '';
+ },
+ instantiate: function() {
+ return "plugin";
+ }
+ }));
+ System['import']('test/file!tests/es6-plugin').then(function(m) {
+ ok(m == 'plugin');
+ start();
+ });
+ });
+
+ asyncTest('Loading a non-registering module', function() {
+ System['import']('tests/global-dep.js')['catch'](function(e) {
+ ok(e.toString().indexOf('did not call System.register or AMD define') != -1);
+ start();
+ });
+ });
+
+ asyncTest('Loading a global with exports defined', function() {
+ System.config({
+ meta: {
+ 'tests/global-single.js': {
+ exports: 'foo'
+ }
+ }
+ });
+ System['import']('tests/global-single.js').then(function(m) {
+ ok(m == 'bar');
+ start();
+ });
+ });
+
+ asyncTest('Loading a precompiled global with exports still defined', function() {
+ System.config({
+ meta: {
+ 'tests/global-single-compiled.js': {
+ exports: 'foobar'
+ }
+ }
+ });
+ System['import']('tests/global-single-compiled.js').then(function(m) {
+ ok(m == 'foo');
+ start();
+ });
+ });
+
+ asyncTest('Importing a script with wrong integrity fails', function() {
+ System.config({
+ meta: {
+ 'tests/csp/integrity.js': {
+ integrity: 'sha256-abc'
+ }
+ }
+ });
+ System['import']('tests/csp/integrity.js').then(err, function(e) {
+ ok(typeof e !== 'undefined');
+ start();
+ });
+ });
+
+ asyncTest('Importing a script with correct integrity', function() {
+ System.config({
+ meta: {
+ 'tests/csp/integrity.js': {
+ integrity: 'sha256-_AfZ2eZSJyVU4HFktUpbsTEoSJF1hL5eGKjgdXZnNTw='
+ }
+ }
+ });
+ System['import']('tests/csp/integrity.js').then(function(m) {
+ ok(m.integrity === 'integrity');
+ start();
+ }, err);
+ });
+
+ asyncTest('Importing jQuery from CDN', function() {
+ System['import']('https://code.jquery.com/jquery-1.11.3.min.js').then(function($) {
+ ok($.fn);
+ start();
+ });
+ });
+
+ asyncTest('Loading package configuration json', function() {
+ System.config({
+ packageConfigPaths: ['tests/testpkg*.json']
+ });
+ System.import('tests/testpkg2')
+ .then(function(m) {
+ ok(m.asdf == 'asdf');
+ start();
+ }, err);
+ })
+ </script>
+ </body>
+</html> \ No newline at end of file