Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Make tests pass on IE11.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Aug 9, 2014
1 parent 1fad80e commit 697a143
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 46 deletions.
9 changes: 2 additions & 7 deletions test/html/dedupe.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@
<script src="../../html-imports.js"></script>
<link rel="import" href="imports/dedupe.html">
<script>
var a = document.createElement('a');
a.href = document.baseURI;
var path = a.pathname.split('/');
path.pop();
//
var link = document.createElement('link');
link.href = path.join('/') + '/imports/dedupe.html';
link.href = 'imports/dedupe.html';
link.rel = 'import';
link.addEventListener('load', function(e) {
console.log('dynamic link loaded', e.target);
console.log('dynamic link loaded', e.target.href);
})
document.head.appendChild(link);
</script>
Expand Down
44 changes: 23 additions & 21 deletions test/html/style-links.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,29 @@

<script>
addEventListener('HTMLImportsLoaded', function() {

var imp = document.head.querySelector('link[rel=import]');
chai.assert.ok(imp.import, 'import has content');

function computedStyle(selector) {
return getComputedStyle(document.querySelector(selector));
}

// styles in stylesheets are applied
chai.assert.equal(computedStyle('.red').backgroundColor, 'rgb(255, 0, 0)');
chai.assert.equal(computedStyle('.orange').backgroundColor, 'rgb(255, 165, 0)');
chai.assert.equal(computedStyle('.blue').backgroundColor, 'rgb(0, 0, 255)');
// styles in stylesheets are applied in the correct order and overriddable
chai.assert.equal(computedStyle('.overridden').backgroundColor, 'rgb(0, 0, 0)');
// styles in style elements are applied
chai.assert.equal(computedStyle('.styled').backgroundColor, 'rgb(255, 0, 0)');
// styles in style are applied in the correct order and overriddable
chai.assert.equal(computedStyle('.overridden-style').backgroundColor, 'rgb(0, 0, 0)');


done();

// NOTE: IE requires asynchrony here
setTimeout(function() {
var imp = document.head.querySelector('link[rel=import]');
chai.assert.ok(imp.import, 'import has content');

function computedStyle(selector) {
return getComputedStyle(document.querySelector(selector));
}
// styles in stylesheets are applied
chai.assert.equal(computedStyle('.red').backgroundColor, 'rgb(255, 0, 0)');
chai.assert.equal(computedStyle('.orange').backgroundColor, 'rgb(255, 165, 0)');
chai.assert.equal(computedStyle('.blue').backgroundColor, 'rgb(0, 0, 255)');
// styles in stylesheets are applied in the correct order and overriddable
chai.assert.equal(computedStyle('.overridden').backgroundColor, 'rgb(0, 0, 0)');
// styles in style elements are applied
chai.assert.equal(computedStyle('.styled').backgroundColor, 'rgb(255, 0, 0)');
// styles in style are applied in the correct order and overriddable
chai.assert.equal(computedStyle('.overridden-style').backgroundColor, 'rgb(0, 0, 0)');


done();
});
});
</script>
</body>
Expand Down
39 changes: 21 additions & 18 deletions test/html/style-paths.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,30 @@
<script>

document.addEventListener('HTMLImportsLoaded', function() {
var i = document.querySelector('[rel=import]');
var doc = i.import;

var red = document.querySelector('.red');
chai.assert.equal(getComputedStyle(red).backgroundColor, 'rgb(255, 0, 0)', 'style in @import applied');
var image = document.querySelector('.image');
// NOTE: IE requires asynchrony here
setTimeout(function() {
var i = document.querySelector('[rel=import]');
var doc = i.import;

var red = document.querySelector('.red');
chai.assert.equal(getComputedStyle(red).backgroundColor, 'rgb(255, 0, 0)', 'style in @import applied');
var image = document.querySelector('.image');

// document relative image url
var a = document.createElement('a');
a.href = 'imports/google.png';
chai.assert.match(getComputedStyle(image).backgroundImage, new RegExp(a.href), 'url in style applied');
// document relative image url
var a = document.createElement('a');
a.href = 'imports/google.png';
chai.assert.match(getComputedStyle(image).backgroundImage, new RegExp(a.href), 'url in style applied');

if (!HTMLImports.useNative) {
var style = document.querySelector('style');
chai.assert.ok(style.sheet);
chai.assert.equal(style.sheet.cssRules[2].href,
'http://fonts.googleapis.com/css?family=Open+Sans:300,300italic,600,800|Source+Code+Pro',
'@import url() form rule has proper url')
}
if (!HTMLImports.useNative) {
var style = document.querySelector('style');
chai.assert.ok(style.sheet);
chai.assert.equal(style.sheet.cssRules[2].href,
'http://fonts.googleapis.com/css?family=Open+Sans:300,300italic,600,800|Source+Code+Pro',
'@import url() form rule has proper url')
}

done();
done();
});
});
</script>
</body>
Expand Down

0 comments on commit 697a143

Please sign in to comment.