Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: LayoutTests/resources/ahem.js

Issue 1207173002: [Temporary] try resources/ahem.js (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/resources/ahem.js
diff --git a/LayoutTests/resources/ahem.js b/LayoutTests/resources/ahem.js
new file mode 100644
index 0000000000000000000000000000000000000000..156b248d3b85f30a11b9c3159cd05bb99618e81e
--- /dev/null
+++ b/LayoutTests/resources/ahem.js
@@ -0,0 +1,19 @@
+// A test using Ahem font includes this file to ensure that the
+// font is loaded before window.onload fires and test finishes.
+// Note: this doesn't work if the test doesn't contain any visible
+// element with 'font-family: Ahem' style.
+(function() {
+ var scripts = document.getElementsByTagName('script');
+ var src = scripts[scripts.length - 1].src;
+ var lastSlash = src.lastIndexOf('/');
+ var relativePath = src.substr(0, lastSlash);
+
+ window.addEventListener('DOMContentLoad', function() {
+ var style = document.createElement('style');
+ style.appendChild(document.createTextNode(
+ '@font-face { font-family: Ahem; src: url(' + relativePath + '/Ahem.ttf'));
+ document.head.appendChild(style);
+ // Force a layout to start loading the font.
+ document.documentElement.offsetTop;
+ }, true);
+}());

Powered by Google App Engine
This is Rietveld 408576698