Files
polymer/test/unit/attached-style.html

63 lines
2.0 KiB
HTML

<!DOCTYPE html>
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="UTF-8">
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script>
addEventListener('WebComponentsReady', function() {
window.elementsReady = true;
// Record layout data at WebComponentsReady time for later testing
var el = document.querySelector('attached-style');
el.offsetParentAtWebComponentsReadyTime = el.offsetParent;
el.offsetHeightAtWebComponentsReadyTime = el.offsetHeight;
});
</script>
<script src="../../../web-component-tester/browser.js"></script>
<link rel="import" href="../../polymer.html">
<link rel="import" href="attached-style-elements.html">
</head>
<body>
<attached-style></attached-style>
<script>
suite('Attached can get computed style data', function() {
var el = document.querySelector('attached-style');
test('style data available at attached time', function() {
assert.equal(el.offsetParentAtAttachedTime, document.body);
assert.equal(el.offsetHeightAtAttachedTime, 100);
});
test('style data available at WebComponentsReady time', function(done) {
function finish() {
assert.equal(el.offsetParentAtWebComponentsReadyTime, document.body);
assert.equal(el.offsetHeightAtWebComponentsReadyTime, 100);
done();
}
if (!window.elementsReady) {
addEventListener('WebComponentsReady', finish);
} else {
finish();
}
})
});
</script>
</body>
</html>