Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/css2-1selectors/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
r: 0
spec: "http://www.w3.org/TR/CSS2/selector.html"
title: "CSS 2.1"
1 change: 1 addition & 0 deletions tests/css2-1selectors/fixture.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<iframe id="css2-1selectors" src="/tests/css2-1selectors/iframe.html"></iframe>
53 changes: 53 additions & 0 deletions tests/css2-1selectors/iframe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html>
<head>
<title>css2-1selectors</title>
<style>
div, span {
border: 1px solid;
}
#descendant div {
border-color: red;
}
#child > div {
border-color: orange;
}
#adjacent + span {
border-color: yellow;
}
[data-foo='bar'] {
border-color: green;
}
#generated {
}
#generated:after {
content: ":|";
visibility: "hidden";
}
</style>
</head>
<body>
<div id="descendant"><span><div class="found"></div></span></div>
<div id="child"><div class="found"><div id="error"></div></div></div>
<div id="adjacent"></div><span class="found"></span>
<div id="attribute" data-foo="bar" class="found"></div>
<p id="generated"></p>

<script>
var results = [],
selectors = [
"#descendant div",
"#child > div",
"#adjacent + span",
"[data-foo='bar']"
];

selectors.forEach(function( selector ) {
var elem = document.querySelector(selector);

results.push( !!getComputedStyle( elem ).getPropertyValue("border-top-color") );
});
top.postMessage( results.join(""), "*" );
</script>
</body>
</html>
33 changes: 33 additions & 0 deletions tests/css2-1selectors/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// TODO: Rewrite to work correctly in opera
// @Mike, @Divya: I promise this is only temporary
if ( !window.opera ) {

asyncTest("CSS 2.1 Selectors", function( async ) {
var iframe = document.getElementById("css2-1selectors").contentWindow;

window.onmessage = function( event ) {
async.step(function() {
assert( event.data === "truetruetruetrue",
"CSS 2.1 Selectors are supported"
);
window.onmessage = null;
async.done();
});
};
});

asyncTest("CSS Generated Content", function( async ) {
var iframe = document.getElementById("css2-1selectors");

iframe.contentWindow.onload = function(e) {
var elem;

async.step(function() {
elem = iframe.contentDocument.getElementById("generated");
assert( elem.offsetHeight >= 1, "CSS generated content modifies the offsetHeight as expected" );
async.done();
});
};
});

}