Skip to content

Commit 7f71b4c

Browse files
committed
Add global leak test.
1 parent cdc9fde commit 7f71b4c

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

‎test/unit/globals.html‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
<html>
12+
<head>
13+
<meta charset="utf-8">
14+
<script src="../../../web-component-tester/browser.js"></script>
15+
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
16+
<script>
17+
window.origOwnProps = Object.getOwnPropertyNames(window).reduce(function(props, prop) {
18+
return props[prop] = true && props;
19+
}, {});
20+
</script>
21+
<link rel="import" href="../../polymer.html">
22+
<body>
23+
24+
<script>
25+
26+
suite('globals', function() {
27+
28+
var expected = {
29+
origOwnProps: true,
30+
31+
// Test harness
32+
a11ySuite: true,
33+
assert: true,
34+
expect: true,
35+
run: true,
36+
37+
// Polymer
38+
Polymer: true,
39+
currentImport: true
40+
};
41+
42+
test('check global leakage', function() {
43+
var newProps = Object.getOwnPropertyNames(window).filter(function(prop) {
44+
return !origOwnProps[prop] && !expected[prop];
45+
});
46+
assert.equal(newProps.length, 0, 'new globals added: \n' + newProps.sort().join('\n'));
47+
});
48+
49+
});
50+
51+
</script>
52+
53+
</body>
54+
</html>

0 commit comments

Comments
 (0)