Ignore custom fonts applied to pseudo elements #442

Merged
merged 1 commit into from Jan 3, 2013
View
@@ -1308,10 +1308,16 @@ def make_the_server_go_away
<head>
<style type="text/css">
p { font-family: "Verdana"; }
+ p:before { font-family: "Verdana"; }
+ p:after { font-family: "Verdana"; }
+ #first-line-div:first-line { font-family: "Verdana"; }
+ #first-letter-div:first-letter { font-family: "Verdana"; }
</style>
</head>
<body>
<p id="text">Hello</p>
+ <p id="first-line-div">Hello first line.</p>
+ <p id="first-letter-div">Hello first letter.</p>
</body>
</html>
HTML
@@ -1326,6 +1332,38 @@ def make_the_server_go_away
SCRIPT
font_family.should == "Arial"
end
+
+ it "ignores custom fonts before an element" do
+ font_family = driver.evaluate_script(<<-SCRIPT)
@jferris

jferris Jan 3, 2013

Owner

There's some duplication in these examples. You could extract a helper method to get the computed style; I think the only variation between the examples is the pseudo-selector (before, after, etc).

+ var element = document.getElementById("text");
+ element.ownerDocument.defaultView.getComputedStyle(element, 'before').getPropertyValue("font-family");
+ SCRIPT
+ font_family.should == "Arial"
+ end
+
+ it "ignores custom fonts after an element" do
+ font_family = driver.evaluate_script(<<-SCRIPT)
+ var element = document.getElementById("text");
+ element.ownerDocument.defaultView.getComputedStyle(element, 'after').getPropertyValue("font-family");
+ SCRIPT
+ font_family.should == "Arial"
+ end
+
+ it "ignores custom fonts applied to the first-line pseudo element" do
+ font_family = driver.evaluate_script(<<-SCRIPT)
+ var element = document.getElementById("first-line-div");
+ element.ownerDocument.defaultView.getComputedStyle(element, 'first-line').getPropertyValue("font-family");
+ SCRIPT
+ font_family.should == "Arial"
+ end
+
+ it "ignores custom fonts applied to the first-letter pseudo element" do
+ font_family = driver.evaluate_script(<<-SCRIPT)
+ var element = document.getElementById("first-letter-div");
+ element.ownerDocument.defaultView.getComputedStyle(element, 'first-letter').getPropertyValue("font-family");
+ SCRIPT
+ font_family.should == "Arial"
+ end
end
context "cookie-based app" do
View
@@ -70,7 +70,7 @@ void WebPage::loadJavascript() {
}
void WebPage::setUserStylesheet() {
- QString data = QString("* { font-family: 'Arial' ! important; }").toUtf8().toBase64();
+ QString data = QString("*, :first-line, :first-letter, :before, :after { font-family: 'Arial' ! important; }").toUtf8().toBase64();
QUrl url = QUrl(QString("data:text/css;charset=utf-8;base64,") + data);
settings()->setUserStyleSheetUrl(url);
}