Override custom fonts, since some of them crash QtWebkit on OS X
This commit is contained in:
parent
d3b9b304f3
commit
82ae0c298f
|
@ -786,6 +786,36 @@ describe Capybara::Driver::Webkit do
|
|||
end
|
||||
end
|
||||
|
||||
context "custom font app" do
|
||||
before(:all) do
|
||||
@app = lambda do |env|
|
||||
body = <<-HTML
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
p { font-family: "Verdana"; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p id="text">Hello</p>
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
[200,
|
||||
{ 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s },
|
||||
[body]]
|
||||
end
|
||||
end
|
||||
|
||||
it "ignores custom fonts" do
|
||||
font_family = subject.evaluate_script(<<-SCRIPT)
|
||||
var element = document.getElementById("text");
|
||||
element.ownerDocument.defaultView.getComputedStyle(element, null).getPropertyValue("font-family");
|
||||
SCRIPT
|
||||
font_family.should == "Arial"
|
||||
end
|
||||
end
|
||||
|
||||
context "with socket debugger" do
|
||||
let(:socket_debugger_class){ Capybara::Driver::Webkit::SocketDebugger }
|
||||
let(:browser_with_debugger){
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
WebPage::WebPage(QObject *parent) : QWebPage(parent) {
|
||||
loadJavascript();
|
||||
setUserStylesheet();
|
||||
|
||||
m_loading = false;
|
||||
|
||||
|
@ -30,6 +31,12 @@ void WebPage::loadJavascript() {
|
|||
}
|
||||
}
|
||||
|
||||
void WebPage::setUserStylesheet() {
|
||||
QString data = QString("* { font-family: 'Arial' ! important; }").toUtf8().toBase64();
|
||||
QUrl url = QUrl(QString("data:text/css;charset=utf-8;base64,") + data);
|
||||
settings()->setUserStyleSheetUrl(url);
|
||||
}
|
||||
|
||||
QString WebPage::userAgentForUrl(const QUrl &url ) const {
|
||||
if (!m_userAgent.isEmpty()) {
|
||||
return m_userAgent;
|
||||
|
|
|
@ -34,5 +34,6 @@ class WebPage : public QWebPage {
|
|||
bool m_loading;
|
||||
QString getLastAttachedFileName();
|
||||
void loadJavascript();
|
||||
void setUserStylesheet();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue