1<!doctype html> 2<!-- 3 @license 4 Copyright (c) 2014 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<title>ScopingShim Tests</title> 12<meta charset="utf-8"> 13 14<script src="../node_modules/wct-browser-legacy/browser.js"></script> 15 16<script> 17(function(){ 18 var suites = [ 19 'css-parse.html', 20 'apply-shim.html', 21 'async-loading.html', 22 'placeholder-ordering.html', 23 'scoping.html', 24 'mixin-ordering.html', 25 'svg.html', 26 'style-transformer.html', 27 'custom-style.html', 28 'custom-style-late.html', 29 'custom-style-only.html', 30 'complicated-mixin-ordering.html', 31 'dynamic-scoping.html', 32 'settings.html', 33 'chrome-devtools.html', 34 'workarounds.html', 35 'deferred-apply.html', 36 'no-applyshim/custom-style-only.html', 37 'wc-1.html', 38 'scoping-api.html', 39 'mixin-fallbacks.html' 40 ]; 41 42 // http://eddmann.com/posts/cartesian-product-in-javascript/ 43 function flatten(arr) { return [].concat.apply([], arr) } 44 function product(sets) { 45 return sets.reduce(function(acc, set) { 46 return flatten(acc.map(function(x) { 47 return set.map(function(y) { return x.concat(y); }); 48 })); 49 }, [[]]); 50 } 51 function combinations(suites, flags) { 52 return product(flags).reduce(function(list, f) { 53 f = f.filter(function(i) { return i; }).join('&'); 54 return list.concat(suites.map(function(s) { return s + (f ? '?' + f : '') })) 55 }, []); 56 } 57 58 function addUrlOption(previous, next) { 59 previous = previous || ''; 60 next = next || ''; 61 return previous + (previous ? '&' : '') + next; 62 } 63 64 // test shadowdom/custom elements polyfills together 65 // prefering both if possible. 66 var matrix = ['']; 67 var webcomponents = ''; 68 if (window.customElements) { 69 webcomponents = 'wc-register=true'; 70 } 71 // if native is available, make sure to test polyfill 72 if (Element.prototype.attachShadow && document.documentElement.getRootNode) { 73 webcomponents = addUrlOption(webcomponents, 'wc-shadydom=true'); 74 } 75 // ce + sd becomes a single test iteration. 76 if (webcomponents) { 77 matrix.push(webcomponents); 78 } 79 // economize testing by testing css shimming 80 // only against 1 environment (native or polyfill). 81 if (window.CSS && CSS.supports && CSS.supports('box-shadow', '0 0 0 var(--foo)')) { 82 var last = matrix[matrix.length-1]; 83 matrix.push(addUrlOption(last, 'wc-shimcssproperties=true')); 84 } 85 suites = combinations(suites, [matrix]); 86 87 var orderingScenarios = [ 88 'wc-order=apply,custom', 89 'wc-order=scoping,apply,custom', 90 'wc-order=apply,early,custom', 91 'wc-order=scoping,early,apply,custom', 92 'wc-order=scoping,apply,early,custom' 93 ]; 94 95 suites = suites.concat(combinations(['ordering.html'], [matrix, orderingScenarios])); 96 97 if (matrix.length > 2) { 98 suites = suites.concat([ 99 'no-scopingshim/apply-shim.html', 100 'no-scopingshim/mixin-ordering.html', 101 'no-scopingshim/custom-style.html', 102 'no-scopingshim/custom-style-late.html', 103 'no-scopingshim/complicated-mixin-ordering.html', 104 'no-scopingshim/custom-style-only.html', 105 'no-applyshim/custom-style.html', 106 'no-applyshim/custom-style-late.html' 107 ]); 108 } 109 110 console.log(suites); 111 WCT.loadSuites(suites); 112})(); 113</script> 114