1<!doctype html>
2<!--
3@license
4Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
5This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8Code distributed by Google as part of the polymer project is also
9subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10-->
11<script>
12  WCT = { waitFor: function (cb) { HTMLImports.whenReady(cb) } }
13</script>
14<script src="./test-flags.js"></script>
15<script src="../node_modules/wct-browser-legacy/browser.js"></script>
16<script src="../node_modules/@webcomponents/webcomponents-platform/webcomponents-platform.js"></script>
17<script src="../node_modules/es6-promise/dist/es6-promise.auto.min.js"></script>
18<script src="../node_modules/@webcomponents/template/template.js"></script>
19<script src="../node_modules/@webcomponents/html-imports/html-imports.min.js"></script>
20<script src="../node_modules/@webcomponents/shadydom/shadydom.min.js"></script>
21<script src="../node_modules/@webcomponents/custom-elements/custom-elements.min.js"></script>
22<script src="../scoping-shim.min.js"></script>
23<script src="../apply-shim.min.js"></script>
24<script src="../custom-style-interface.min.js"></script>
25<script src="module/generated/make-element.js"></script>
26
27<template id="mixin-element">
28  <style>
29    :host {
30      background-color: rgb(0, 0, 255);
31      height: 100px;
32      display: block;
33    }
34    :host {
35      @apply --mixin;
36    }
37  </style>
38</template>
39
40<template id="outer-element">
41  <style>
42    :host > * {
43      --mixin: {
44        background-color: rgb(255, 0, 0);
45      }
46    }
47  </style>
48  <mixin-element></mixin-element>
49</template>
50
51<script>
52  suite('Mixin Fallbacks', function() {
53    suiteSetup(function() {
54      makeElement('mixin-element');
55      makeElement('outer-element');
56    });
57
58    test('outer-element sets mixin color', function() {
59      const el = document.createElement('outer-element');
60      document.body.appendChild(el);
61      const inner = el.shadowRoot.querySelector('mixin-element');
62      const color = getComputedStyle(inner).getPropertyValue('background-color').trim();
63      assert.equal(color, 'rgb(255, 0, 0)');
64    });
65    test('mixin-element by itself falls back correctly', function() {
66      const mixinOnly = document.createElement('mixin-element');
67      document.body.appendChild(mixinOnly);
68      const color = getComputedStyle(mixinOnly).getPropertyValue('background-color').trim();
69      assert.equal(color, 'rgb(0, 0, 255)');
70    });
71  });
72</script>