Skip to content

Commit

Permalink
In tests, explicitly write to window when creating a new global for c…
Browse files Browse the repository at this point in the history
…larity.
  • Loading branch information
rictic committed Aug 3, 2017
1 parent 06c6ea0 commit 674d468
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 52 deletions.
36 changes: 18 additions & 18 deletions test/unit/behaviors.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<script>
HTMLImports.whenReady(function() {
Polymer.BehaviorA = {
window.BehaviorA = {
properties: {

label: {
Expand Down Expand Up @@ -87,7 +87,7 @@
}
};

Polymer.BehaviorB = {
window.BehaviorB = {
properties: {

disabled: {
Expand Down Expand Up @@ -136,7 +136,7 @@
},
};

Polymer.BehaviorC = {
window.BehaviorC = {

properties: {

Expand All @@ -149,7 +149,7 @@
_simpleProperty: 'C'
};

Polymer.BehaviorD = {
window.BehaviorD = {

properties: {

Expand All @@ -166,7 +166,7 @@
is: 'single-behavior',

behaviors: [
Polymer.BehaviorA
window.BehaviorA
],

properties: {},
Expand All @@ -179,8 +179,8 @@
is: 'multi-behaviors',

behaviors: [
Polymer.BehaviorA,
Polymer.BehaviorB
window.BehaviorA,
window.BehaviorB
],

hostAttributes: {
Expand Down Expand Up @@ -211,12 +211,12 @@
is: 'nested-behaviors',

behaviors: [
[Polymer.BehaviorB, [Polymer.BehaviorC, Polymer.BehaviorB], Polymer.BehaviorA],
[Polymer.BehaviorD]
[window.BehaviorB, [window.BehaviorC, window.BehaviorB], window.BehaviorA],
[window.BehaviorD]
]
});

Polymer.registerBehavior1 ={
window.registerBehavior1 ={
beforeRegister: function() {
this._createPropertyObserver('beforeProp', 'beforePropChanged1');
this.beforeRegisterCount++;
Expand Down Expand Up @@ -244,7 +244,7 @@
}
};

Polymer.registerBehavior2 ={
window.registerBehavior2 ={
prop2: true,
beforeRegister: function() {
this.beforeRegisterCount++;
Expand All @@ -254,7 +254,7 @@
}
};

Polymer.registerBehavior3 ={
window.registerBehavior3 ={
prop3: true,
beforeRegister: function() {
this.beforeRegisterCount++;
Expand All @@ -266,9 +266,9 @@

Polymer({
behaviors: [
Polymer.registerBehavior1,
Polymer.registerBehavior2,
Polymer.registerBehavior3
window.registerBehavior1,
window.registerBehavior2,
window.registerBehavior3
],
prop4: true,
beforeRegister: function() {
Expand Down Expand Up @@ -468,18 +468,18 @@
test('behavior array is unique', function() {
Polymer({
is: 'behavior-unique',
behaviors: [Polymer.BehaviorA, Polymer.BehaviorA]
behaviors: [window.BehaviorA, window.BehaviorA]
});
assert.equal(document.createElement('behavior-unique').behaviors.length, 1);
});

test('duplicate behaviors keep first behavior', function() {
Polymer({
is: 'behavior-unique-last-behavior',
behaviors: [Polymer.BehaviorA, Polymer.BehaviorB, Polymer.BehaviorC, Polymer.BehaviorA, Polymer.BehaviorB]
behaviors: [window.BehaviorA, window.BehaviorB, window.BehaviorC, window.BehaviorA, window.BehaviorB]
});
var behaviors = document.createElement('behavior-unique-last-behavior').behaviors;
assert.deepEqual(behaviors, [Polymer.BehaviorC, Polymer.BehaviorA, Polymer.BehaviorB]);
assert.deepEqual(behaviors, [window.BehaviorC, window.BehaviorA, window.BehaviorB]);
});

});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/configure.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</head>
<body>
<script>
var configureBehavior = {
window.configureBehavior = {

changeHandlerCount: 0,
objectChangeHandlerCount: 0,
Expand Down
42 changes: 21 additions & 21 deletions test/unit/mixin-behaviors.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<script>
HTMLImports.whenReady(function() {
Polymer.LifeCycleBehavior1 = {
window.LifeCycleBehavior1 = {
_calledCreated: 0,
_calledAttached: 0,
_calledAttributeChanged: 0,
Expand All @@ -42,7 +42,7 @@
}
};

Polymer.LifeCycleBehavior2 = {
window.LifeCycleBehavior2 = {
created() {
this._calledCreated++;
},
Expand All @@ -53,7 +53,7 @@

};

Polymer.BehaviorA = {
window.BehaviorA = {
properties: {

label: {
Expand Down Expand Up @@ -116,7 +116,7 @@
}
};

Polymer.BehaviorB = {
window.BehaviorB = {
properties: {

disabled: {
Expand Down Expand Up @@ -166,7 +166,7 @@

};

Polymer.BehaviorC = {
window.BehaviorC = {

properties: {

Expand All @@ -179,7 +179,7 @@
_simpleProperty: 'C'
};

Polymer.BehaviorD = {
window.BehaviorD = {

properties: {

Expand All @@ -198,7 +198,7 @@
<script>
HTMLImports.whenReady(function() {
customElements.define('single-behavior',
Polymer.mixinBehaviors(Polymer.BehaviorA, Polymer.Element));
Polymer.mixinBehaviors(window.BehaviorA, Polymer.Element));
});
</script>
</dom-module>
Expand All @@ -207,8 +207,8 @@
<script>
HTMLImports.whenReady(function() {
customElements.define('lifecycle-behavior',
Polymer.mixinBehaviors([Polymer.LifeCycleBehavior1,
Polymer.LifeCycleBehavior2], Polymer.Element));
Polymer.mixinBehaviors([window.LifeCycleBehavior1,
window.LifeCycleBehavior2], Polymer.Element));
});
</script>
</dom-module>
Expand All @@ -218,7 +218,7 @@
HTMLImports.whenReady(function() {
customElements.define('multi-behaviors',
class extends Polymer.mixinBehaviors(
[Polymer.BehaviorA, Polymer.BehaviorB], Polymer.Element) {
[window.BehaviorA, window.BehaviorB], Polymer.Element) {

static get properties() {
return {
Expand Down Expand Up @@ -258,8 +258,8 @@
customElements.define('nested-behaviors',
class extends Polymer.mixinBehaviors(
[
[Polymer.BehaviorB, [Polymer.BehaviorC, Polymer.BehaviorB], Polymer.BehaviorA],
[Polymer.BehaviorD]
[window.BehaviorB, [window.BehaviorC, window.BehaviorB], window.BehaviorA],
[window.BehaviorD]
], Polymer.Element) {
});
});
Expand All @@ -273,7 +273,7 @@
<script>
HTMLImports.whenReady(function() {

Polymer.registerBehavior1 ={
window.registerBehavior1 ={
registered: function() {
this._createPropertyObserver('prop', 'propChanged1');
this._createMethodObserver('propChanged2(prop)');
Expand All @@ -293,24 +293,24 @@
}
};

Polymer.registerBehavior2 ={
window.registerBehavior2 ={
prop2: true,
registered: function() {
this.registeredCount++;
}
};

Polymer.registerBehavior3 ={
window.registerBehavior3 ={
prop3: true,
registered: function() {
this.registeredCount++;
}
};

class BehaviorRegistered extends Polymer.mixinBehaviors([
Polymer.registerBehavior1,
Polymer.registerBehavior2,
Polymer.registerBehavior3
window.registerBehavior1,
window.registerBehavior2,
window.registerBehavior3
], Polymer.Element) {

static get is() { return 'behavior-registered'}
Expand Down Expand Up @@ -531,15 +531,15 @@

test('behavior array is unique', function() {
customElements.define('behavior-unique', Polymer.mixinBehaviors(
[Polymer.BehaviorA, Polymer.BehaviorA], Polymer.Element));
[window.BehaviorA, window.BehaviorA], Polymer.Element));
assert.equal(document.createElement('behavior-unique').behaviors.length, 1);
});

test('duplicate behaviors keep first behavior', function() {
customElements.define('behavior-unique-last-behavior', Polymer.mixinBehaviors(
[Polymer.BehaviorA, Polymer.BehaviorB, Polymer.BehaviorC, Polymer.BehaviorA, Polymer.BehaviorB], Polymer.Element));
[window.BehaviorA, window.BehaviorB, window.BehaviorC, window.BehaviorA, window.BehaviorB], Polymer.Element));
var behaviors = document.createElement('behavior-unique-last-behavior').behaviors;
assert.deepEqual(behaviors, [Polymer.BehaviorC, Polymer.BehaviorA, Polymer.BehaviorB]);
assert.deepEqual(behaviors, [window.BehaviorC, window.BehaviorA, window.BehaviorB]);
});

});
Expand Down
24 changes: 12 additions & 12 deletions test/unit/property-effects-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class XElementChild extends Polymer.Element {
ready() {
super.ready();
Polymer.lifecycleOrder.log(this, 'ready');
window.lifecycleOrder.log(this, 'ready');
}
}
customElements.define('x-element-child', XElementChild);
Expand All @@ -50,7 +50,7 @@
}
ready() {
super.ready();
Polymer.lifecycleOrder.log(this, 'ready');
window.lifecycleOrder.log(this, 'ready');
}
}
customElements.define('x-element', XElement);
Expand Down Expand Up @@ -121,7 +121,7 @@
ready() {
super.setAttribute('log', '');
super.ready();
Polymer.lifecycleOrder.log(this, 'ready');
window.lifecycleOrder.log(this, 'ready');
}
compute(a, b) {
return `[${a} - ${b}]`;
Expand Down Expand Up @@ -280,7 +280,7 @@
let el;

setup(function() {
Polymer.lifecycleOrder = {
window.lifecycleOrder = {
log(el, lifecycle) {
if (this.shouldLog(el)) {
let list = this[lifecycle] = this[lifecycle] || [];
Expand Down Expand Up @@ -344,7 +344,7 @@
assert.equal(stamped.length, 1);
assert.equal(stamped[0], el.$.first);
// Lifecycle order correct
assert.deepEqual(Polymer.lifecycleOrder.ready, [
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
Expand All @@ -360,7 +360,7 @@
assert.equal(stamped.length, 2);
assert.equal(stamped[0], el.$.first);
assert.equal(stamped[1], dom.$.first);
assert.deepEqual(Polymer.lifecycleOrder.ready, [
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
Expand Down Expand Up @@ -407,7 +407,7 @@
assert.equal(stamped[0], el.$.first);
assert.equal(stamped[1], dom2.$.first);
assert.equal(stamped[2], dom3.$.first);
assert.deepEqual(Polymer.lifecycleOrder.ready, [
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
Expand Down Expand Up @@ -444,7 +444,7 @@
assert.equal(stamped.length, 2);
assert.equal(stamped[0], el.$.first);
assert.equal(stamped[1], dom.$.first);
assert.deepEqual(Polymer.lifecycleOrder.ready, [
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
Expand Down Expand Up @@ -491,7 +491,7 @@
assert.equal(stamped[0], el.$.first);
assert.equal(stamped[1], dom2.$.first);
assert.equal(stamped[2], dom3.$.first);
assert.deepEqual(Polymer.lifecycleOrder.ready, [
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
Expand Down Expand Up @@ -528,7 +528,7 @@
assert.equal(stamped.length, 2);
assert.equal(stamped[0], el.$.first);
assert.equal(stamped[1], dom.$.first);
assert.deepEqual(Polymer.lifecycleOrder.ready, [
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
Expand Down Expand Up @@ -572,7 +572,7 @@
assert.equal(stamped[0], el.$.first);
assert.equal(stamped[1], dom2.$.first);
assert.equal(stamped[2], dom3.$.first);
assert.deepEqual(Polymer.lifecycleOrder.ready, [
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
Expand Down Expand Up @@ -676,7 +676,7 @@
assert.equal(stamped.length, 1);
assert.equal(stamped[0], el.$.first);
// Lifecycle order correct
assert.deepEqual(Polymer.lifecycleOrder.ready, [
assert.deepEqual(window.lifecycleOrder.ready, [
'x-runtime|x-element#proto|x-element-child#noBinding',
'x-runtime|x-element#proto|x-element-child#hasBinding',
'x-runtime|x-element#proto',
Expand Down

0 comments on commit 674d468

Please sign in to comment.