Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the need for a timeout in smoke test for font loading #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mgrandrath
Copy link

I wired up the font loading events to PhantomJS.

  • The callback onInitialized is called before the page is loaded (especially before the IIFE with the TypeKit boilerplate is executed).
  • It defines callbacks for fontactive and done in the browser's global namespace. The loaded fonts get stored in a local array. When done is called PhantomJS is notified via callPhantom (which is provided by PhantomJS).
  • callPhantom triggers page.onCallback with the collected fonts array as argument (Note: only serializable data can be exchanged this way).
  • On the client side, the callbacks that are defined via PhantomJS are assigned to the config object (or a no-op function if they are undefined, which will be the case outside of the smoke test).

Remaining problems

  • The test does not feel terribly faster. I don't know if there are any PhantomJS settings or other tweaks that would improve this.
  • The call to phantom.exit() is now within onCallback which is less than ideal. Either should there be a mechanism for collecting asynchronous test results or each test should go into its own file. The former is probably better for performance (because of spawning less processes) while the latter is generally simpler and makes it easier to organize the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant