Permalink
Browse files

Ignore custom fonts applied to pseudo elements

WebPage::setUserStylesheet prevents Web Fonts from loading when styles
are applied directly to elements, however if the styles are applied to
pseudo elements, the override does not apply. This leads to crashes on
Mac OS X, likely due to https://bugs.webkit.org/show_bug.cgi?id=61031.
  • Loading branch information...
1 parent 5dab9f7 commit 11c596f7a06dbda123c077440f9275905f89e869 @mhoran mhoran committed Jan 1, 2013
Showing with 39 additions and 1 deletion.
  1. +38 −0 spec/driver_spec.rb
  2. +1 −1 src/WebPage.cpp
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)
+ 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);
}

0 comments on commit 11c596f

Please sign in to comment.