Created
November 6, 2013 21:58
-
-
Save bradjasper/7344832 to your computer and use it in GitHub Desktop.
This tests aborting font files from TypeKit web fonts. This doesn't work as expected.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page = require('webpage').create(); | |
// Block fonts | |
var abort_content_types = [ | |
"application/x-font-woff", | |
"font/woff", | |
"font/opentype", | |
]; | |
// Default user agent won't work with TypeKit | |
page.settings.userAgent = 'Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7'; | |
page.onResourceRequested = function(resourceData, res) { | |
if (abort_content_types.indexOf(resourceData["contentType"]) != -1) { | |
console.log("Found contentType we should abort = " + resourceData["contentType"]); | |
res.abort(); | |
} | |
}; | |
page.onResourceReceived = function(res) { | |
if (abort_content_types.indexOf(res["contentType"]) != -1) { | |
console.log("ERROR: Should have aborted content, but received it = " + res["contentType"]); | |
} | |
} | |
page.open('https://typekit.com/fonts', function () { | |
page.render('typekit.png'); | |
phantom.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment