Skip to content

Commit

Permalink
Merge pull request #58 from /issues/55-remove-crbug389566-workaround
Browse files Browse the repository at this point in the history
Add test-case and remove workaround for fixed chromium bug,
  • Loading branch information
tomalec authored Aug 28, 2018
2 parents 4eb8ac1 + 0f8bce9 commit bef7425
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 9 deletions.
15 changes: 7 additions & 8 deletions imported-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,13 @@

that.pending = false;
};
// guessed workaround for StarcounterSamples/Launcher#82, Polymer/polymer#554, http://crbug.com/389566
// TODO(tomalec): check if it's still required
setTimeout(function appendAsync() {
document.head.appendChild(link);
that.dispatchEvent(new CustomEvent("stamped", {
detail: that.stampedNodes
}));
});

// Start importing
document.head.appendChild(link);
that.dispatchEvent(new CustomEvent("stamped", {
detail: that.stampedNodes
}));

return this;
}
/**
Expand Down
3 changes: 2 additions & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
'use-cases/previousElementSibling/previousElementSibling.html',
'use-cases/dom-bind/dom-bind.html',
'use-cases/dom-bind/dom-repeat.html',
'use-cases/dom-bind/notify-dom-bind.html'
'use-cases/dom-bind/notify-dom-bind.html',
'use-cases/chromiumBugs.html'
]);
</script>
</body>
Expand Down
63 changes: 63 additions & 0 deletions test/use-cases/chromiumBugs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!doctype html>
<html>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">

<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../../web-component-tester/browser.js"></script>

<!-- Step 1: import the element to test -->
<link rel="import" href="../../imported-template.html">
</head>

<body>

<div id="other-element">foo</div>
<!-- You can use the document as a place to set up your fixtures. -->
<test-fixture id="imported-template-fixture">
<template>
<div>
<!-- nest to workaround test-fixture bug -->
<imported-template href="../mock/smth.html">
</imported-template>
</div>
</template>
</test-fixture>

<script>
describe('<imported-template>', function() {
var myElContainer;

context('when element is connected is being loaded', function() {
before(function() {
myElContainer = fixture('imported-template-fixture');
});
it('`offsetWidth` of already loaded elements should point return correct (non-zero) value', function(){
expect(document.querySelector('#other-element').offsetWidth).to.equal(document.body.offsetWidth);

});
});
context('when partial (HTML Import resource) is being loaded', function() {
let element;
before(function() {
myElContainer = document.createElement('div');
document.body.appendChild(myElContainer);
element = document.createElement('imported-template');
});
it('`offsetWidth` of already loaded elements should point return correct (non-zero) value', function(done){
element.addEventListener('stamped', function whenImporting(){
expect(document.querySelector('#other-element').offsetWidth).to.equal(document.body.offsetWidth);
done();
});
myElContainer.appendChild(element);
element.setAttribute('href', '../mock/smth.html');
});
});
});
</script>

</body>

</html>

0 comments on commit bef7425

Please sign in to comment.