Permalink
Browse files

Modules with hooks needs them to be set in the window where fonts are…

… loading

This was a misunderstanding of how hooks work on my part. Whoops! @ryanwolf
was right the first time.
  • Loading branch information...
1 parent e158272 commit 16ea85ba19adfd38099567a1fd8b1e76fd638e1a Sean McBride committed Dec 5, 2012
@@ -42,9 +42,8 @@ FontdeckScriptTest.prototype.testSupportAndLoadLifecycle = function() {
};
var insert = '';
var global = {
- location: {
- hostname: 'test-host-name'
- }
+ // No hostname to verify fallback behavior for empty iframe
+ location: {}
};
var src = '';
var fakeDomHelper = {
@@ -55,13 +54,14 @@ FontdeckScriptTest.prototype.testSupportAndLoadLifecycle = function() {
src = srcLink;
},
getLoadWindow: function() {
- // No hostname to verify fallback behavior for empty iframe
- return {
- location: {}
- };
+ return global;
},
getMainWindow: function() {
- return global;
+ return {
+ location: {
+ hostname: 'test-host-name'
+ }
+ };
},
getProtocol: function() {
return 'https:';
@@ -98,7 +98,7 @@ FontdeckScriptTest.prototype.testNoProjectId = function() {
var insert = '';
var src = '';
var fakeDomHelper = {
- getMainWindow: function() {
+ getLoadWindow: function() {
return {};
}
};
@@ -21,7 +21,7 @@ MonotypeScriptTest.prototype.testIfScriptTagIsAdded = function () {
script.onload();
}
},
- getMainWindow: function () {
+ getLoadWindow: function () {
return global;
},
getProtocol: function () {
@@ -80,7 +80,7 @@ MonotypeScriptTest.prototype.testIfScriptTagHasCorrectSSL = function () {
script.onload();
}
},
- getMainWindow: function () {
+ getLoadWindow: function () {
return global;
},
getProtocol: function () {
@@ -152,7 +152,7 @@ MonotypeScriptTest.prototype.testIfScriptTagIsAddedWithoutApiurl = function () {
script.onload();
}
},
- getMainWindow: function () {
+ getLoadWindow: function () {
return global;
},
getProtocol: function () {
@@ -212,7 +212,7 @@ MonotypeScriptTest.prototype.testIfScriptTagIsAddedWithoutApiurlAndTheScriptUrlH
script.onload();
}
},
- getMainWindow: function () {
+ getLoadWindow: function () {
return global;
},
getProtocol: function () {
@@ -272,7 +272,7 @@ MonotypeScriptTest.prototype.testWithoutProjectId = function () {
script.onload();
}
},
- getMainWindow: function () {
+ getLoadWindow: function () {
return global;
},
getProtocol: function () {
@@ -14,7 +14,7 @@ TypekitScriptTest.prototype.testSupportAndLoadLifecycle = function() {
createScriptSrc: function(srcLink) {
src = srcLink;
},
- getMainWindow: function() {
+ getLoadWindow: function() {
return global;
},
getProtocol: function() {
@@ -79,7 +79,7 @@ TypekitScriptTest.prototype.testLoadWithVariations = function() {
createScriptSrc: function(srcLink) {
src = srcLink;
},
- getMainWindow: function() {
+ getLoadWindow: function() {
return global;
},
getProtocol: function() {
@@ -142,7 +142,7 @@ TypekitScriptTest.prototype.testAlternateApi = function() {
createScriptSrc: function(srcLink) {
src = srcLink;
},
- getMainWindow: function() {
+ getLoadWindow: function() {
return {};
},
getProtocol: function() {
@@ -171,7 +171,7 @@ TypekitScriptTest.prototype.testNoKitId = function() {
createScriptSrc: function(srcLink) {
src = srcLink;
},
- getMainWindow: function() {
+ getLoadWindow: function() {
return {};
},
getProtocol: function() {
@@ -24,18 +24,18 @@ webfont.FontdeckScript.prototype.getScriptSrc = function(projectId) {
webfont.FontdeckScript.prototype.supportUserAgent = function(userAgent, support) {
var projectId = this.configuration_['id'];
- var mainWindow = this.domHelper_.getMainWindow();
+ var loadWindow = this.domHelper_.getLoadWindow();
var self = this;
if (projectId) {
// Provide data to Fontdeck for processing.
- if (!mainWindow[webfont.FontdeckScript.HOOK]) {
- mainWindow[webfont.FontdeckScript.HOOK] = {};
+ if (!loadWindow[webfont.FontdeckScript.HOOK]) {
+ loadWindow[webfont.FontdeckScript.HOOK] = {};
}
// Fontdeck will call this function to indicate support status
// and what fonts are provided.
- mainWindow[webfont.FontdeckScript.HOOK][projectId] = function(fontdeckSupports, data) {
+ loadWindow[webfont.FontdeckScript.HOOK][projectId] = function(fontdeckSupports, data) {
for (var i = 0, j = data['fonts'].length; i<j; ++i) {
var font = data['fonts'][i];
// Add the FVDs
@@ -50,10 +50,10 @@ webfont.MonotypeScript.prototype.supportUserAgent = function (userAgent, support
}
};
- var mainWindow = this.domHelper_.getMainWindow();
+ var loadWindow = this.domHelper_.getLoadWindow();
sc["onload"] = function (e) {
- if (mainWindow[webfont.MonotypeScript.HOOK + projectId]) {
- var mti_fnts = mainWindow[webfont.MonotypeScript.HOOK + projectId]();
+ if (loadWindow[webfont.MonotypeScript.HOOK + projectId]) {
+ var mti_fnts = loadWindow[webfont.MonotypeScript.HOOK + projectId]();
if (mti_fnts && mti_fnts.length) {
var i;
for (i = 0; i < mti_fnts.length; i++) {
@@ -20,18 +20,18 @@ webfont.TypekitScript.prototype.getScriptSrc = function(kitId) {
webfont.TypekitScript.prototype.supportUserAgent = function(userAgent, support) {
var kitId = this.configuration_['id'];
var configuration = this.configuration_;
- var mainWindow = this.domHelper_.getMainWindow();
+ var loadWindow = this.domHelper_.getLoadWindow();
var self = this;
if (kitId) {
- // Provide data to Typekit for processing.
- if (!mainWindow[webfont.TypekitScript.HOOK]) {
- mainWindow[webfont.TypekitScript.HOOK] = {};
+ // Provide data to Typekit for processing.main
+ if (!loadWindow[webfont.TypekitScript.HOOK]) {
+ loadWindow[webfont.TypekitScript.HOOK] = {};
}
// Typekit will call 'init' to indicate whether it supports fonts
// and what fonts will be provided.
- mainWindow[webfont.TypekitScript.HOOK][kitId] = function(callback) {
+ loadWindow[webfont.TypekitScript.HOOK][kitId] = function(callback) {
var init = function(typekitSupports, fontFamilies, fontVariations) {
self.fontFamilies_ = fontFamilies;
self.fontVariations_ = fontVariations;

0 comments on commit 16ea85b

Please sign in to comment.