Skip to content

sync #1

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

Merged
merged 13 commits into from
Mar 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
v1.6.28 (March 27, 2017)

* Clear timer timeout when promise resolves.

v1.6.27 (November 29, 2016)

* Disable native font loading for Safari 10

v1.6.26 (July 8, 2016)

* Add support for latin extended in the Google Fonts module.
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Web Font Loader gives you added control when using linked fonts via `@font-face`
To use the Web Font Loader library, just include it in your page and tell it which fonts to load. For example, you could load fonts from [Google Fonts](http://www.google.com/fonts/) using the Web Font Loader hosted on [Google Hosted Libraries](https://developers.google.com/speed/libraries/) using the following code.

```html
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.16/webfont.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js"></script>
<script>
WebFont.load({
google: {
Expand All @@ -36,7 +36,7 @@ To use the Web Font Loader library, just include it in your page and tell it whi
</script>
```

Alternatively, you can link to the latest `1.x` version of the Web Font Loader by using `https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js` as the `script` source. Note that the version in this url is less specific. It will always load the latest `1.x` version, but it also has a shorter cache time to ensure that your page gets updates in a timely manner. For performance reasons, we recommend using an explicit version number (such as `1.6.16`) in urls when using the Web Font Loader in production. You can manually update the Web Font Loader version number in the url when you want to adopt a new version.
Alternatively, you can link to the latest `1.x` version of the Web Font Loader by using `https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js` as the `script` source. Note that the version in this url is less specific. It will always load the latest `1.x` version, but it also has a shorter cache time to ensure that your page gets updates in a timely manner. For performance reasons, we recommend using an explicit version number (such as `1.6.26`) in urls when using the Web Font Loader in production. You can manually update the Web Font Loader version number in the url when you want to adopt a new version.

Web Font Loader is also available on the [jsDelivr](http://www.jsdelivr.com/projects/webfontloader) & [CDNJS](https://cdnjs.com/libraries/webfont) CDNs.

Expand All @@ -50,7 +50,8 @@ It is also possible to use the Web Font Loader asynchronously. For example, to l

(function(d) {
var wf = d.createElement('script'), s = d.scripts[0];
wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.16/webfont.js';
wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';
wf.async = true;
s.parentNode.insertBefore(wf, s);
})(document);
</script>
Expand Down Expand Up @@ -384,7 +385,7 @@ If `providerA` can serve fonts to a browser, but `providerB` cannot, The `fontin

## Copyright and License

Web Font Loader Copyright (c) 2010 Adobe Systems Incorporated, Google Incorporated.
Web Font Loader Copyright (c) 2010-2017 Adobe Systems Incorporated, Google Incorporated.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Expand Down
2 changes: 1 addition & 1 deletion lib/webfontloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'webfontloader/modules'

module WebFontLoader
VERSION = '1.6.26'
VERSION = '1.6.28'

ProjectRoot = File.expand_path(File.dirname(__FILE__) + "/..")

Expand Down
6 changes: 3 additions & 3 deletions lib/webfontloader/demo/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class Server < Sinatra::Base
DemoRoot = File.expand_path(File.join(File.dirname(__FILE__)))
ProjectRoot = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", ".."))

GoogleApi = "http://fonts.googleapis.com/css"
GoogleFontApi = "http://themes.googleusercontent.com/font"
GoogleApi = "https://fonts.googleapis.com/css"
GoogleFontApi = "https://themes.googleusercontent.com/font"

set :app_file, __FILE__
set :sessions, false
Expand Down Expand Up @@ -43,7 +43,7 @@ class Server < Sinatra::Base
headers 'Cache-Control' => 'max-age=300'
response = open(url, 'User-Agent' => env['HTTP_USER_AGENT'])
source = response.read
source.gsub!(%r[http://themes.googleusercontent.com/font], '/fonts/font')
source.gsub!(%r[https://themes.googleusercontent.com/font], '/fonts/font')
source
end

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webfontloader",
"version": "1.6.26",
"version": "1.6.28",
"description": "Web Font Loader gives you added control when using linked fonts via @font-face.",
"main": "webfontloader.js",
"scripts": {
Expand Down
94 changes: 0 additions & 94 deletions spec/core/domhelper_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,100 +405,6 @@ describe('DomHelper', function () {
});
});

describe('#getProtocol', function () {
it('should return http', function () {
var domHelper = new DomHelper({
location: {
protocol: 'http:'
}
});

expect(domHelper.getProtocol()).toEqual('http:');
});

it('should return https', function () {
var domHelper = new DomHelper({
location: {
protocol: 'https:'
}
});

expect(domHelper.getProtocol()).toEqual('https:');
});

it('should return the protocol from an iframe', function () {
var domHelper = new DomHelper({
location: {
protocol: 'https:'
}
}, {
location: {
protocol: 'http:'
}
});

expect(domHelper.getProtocol()).toEqual('http:');
});

it('should return the protocol from the main window if the iframe has no protocol', function () {
var domHelper = new DomHelper({
location: {
protocol: 'http:'
}
}, {
location: {
protocol: 'about:'
}
});

expect(domHelper.getProtocol()).toEqual('http:');
});
});

describe('#setProtocol', function () {
it('ignores invalid values', function () {
var domHelper = new DomHelper({
location: 'http:'
});

domHelper.setProtocol('huh');

expect(domHelper.getProtocol()).toEqual('http:');
});

it('overrides the global value', function () {
var domHelper = new DomHelper({
location: 'http:'
});

domHelper.setProtocol('https:');

expect(domHelper.getProtocol()).toEqual('https:');
});
});

describe('#isHttps', function () {
it('should return true if the protocol is https', function () {
var domHelper = new DomHelper({
location: {
protocol: 'https:'
}
});

expect(domHelper.isHttps()).toBe(true);
});

it('should return false if the protocol is not https', function () {
var domHelper = new DomHelper({
location: {
protocol: 'http:'
}
});

expect(domHelper.isHttps()).toBe(false);
});
});

describe('#getHostname', function () {
it('should return the hostname', function () {
var domHelper = new DomHelper({
Expand Down
6 changes: 6 additions & 0 deletions spec/core/fontwatcher_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ describe('FontWatcher', function () {
spyOn(FontWatcher, 'getUserAgent').andReturn('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:43.0) Gecko/20100101 Firefox/43.0');
expect(FontWatcher.shouldUseNativeLoader()).toEqual(true);
});

it('is disabled on Safari > 10', function () {
spyOn(FontWatcher, 'getUserAgent').andReturn('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0.1 Safari/602.2.14');
spyOn(FontWatcher, 'getVendor').andReturn('Apple');
expect(FontWatcher.shouldUseNativeLoader()).toEqual(false);
});
});
}

Expand Down
6 changes: 3 additions & 3 deletions spec/modules/custom_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('modules.Custom', function () {

var defaultModule = new Custom(fakeDomHelper, {
families: ['Font1', 'Font2', 'Font3'],
urls: ['http://moo', 'http://meuh'],
urls: ['https://moo', 'https://meuh'],
testStrings: {
Font3: 'hello world'
}
Expand All @@ -35,8 +35,8 @@ describe('modules.Custom', function () {

it('should have inserted the links correctly', function () {
expect(fakeDomHelper.loadStylesheet.callCount).toEqual(2);
expect(fakeDomHelper.loadStylesheet).toHaveBeenCalledWith('http://moo', new Any(Function));
expect(fakeDomHelper.loadStylesheet).toHaveBeenCalledWith('http://meuh', new Any(Function));
expect(fakeDomHelper.loadStylesheet).toHaveBeenCalledWith('https://moo', new Any(Function));
expect(fakeDomHelper.loadStylesheet).toHaveBeenCalledWith('https://meuh', new Any(Function));
});

if (webfont.DomHelper.CAN_WAIT_STYLESHEET) {
Expand Down
21 changes: 10 additions & 11 deletions spec/modules/fontdeck_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ describe('modules.Fontdeck', function () {

var apiResponse = {
"domain" : "localhost",
"cssurl" : "http://f.fontdeck.com/s/css/03BmCXiV2AHwX/Rp+OBFTfD2oFs/localhost/2282.css",
"cssurl" : "https://f.fontdeck.com/s/css/03BmCXiV2AHwX/Rp+OBFTfD2oFs/localhost/2282.css",
"project" : 2282,
"cssbase" : "http://f.fontdeck.com/s/css/03BmCXiV2AHwX/Rp+OBFTfD2oFs",
"cssbase" : "https://f.fontdeck.com/s/css/03BmCXiV2AHwX/Rp+OBFTfD2oFs",
"fonts" : [
{
"font_family" : "'Fertigo Pro Regular', Fertigo, Constantia, Palatino, serif",
Expand All @@ -19,10 +19,10 @@ describe('modules.Fontdeck', function () {
"style" : "normal",
"weight" : "normal",
"font_urls" : {
"eot" : "http://f.fontdeck.com/f/1/SUlFR0tid0kAA2vb11Ly/IGWDK+wV8TMAfV0J1Ej1J1GFRT1bssqrn6a.eot",
"ttf" : "http://f.fontdeck.com/f/1/SUlFR0tid0kAA2vb11Ly/IGWDK+wV8TMAfV0J1Ej1J1GFRT1bssqrn6a.ttf",
"woff" : "http://f.fontdeck.com/f/1/SUlFR0tid0kAA2vb11Ly/IGWDK+wV8TMAfV0J1Ej1J1GFRT1bssqrn6a.woff",
"svg" : "http://f.fontdeck.com/f/1/SUlFR0tid0kAA2vb11Ly/IGWDK+wV8TMAfV0J1Ej1J1GFRT1bssqrn6a.svg#104"
"eot" : "https://f.fontdeck.com/f/1/SUlFR0tid0kAA2vb11Ly/IGWDK+wV8TMAfV0J1Ej1J1GFRT1bssqrn6a.eot",
"ttf" : "https://f.fontdeck.com/f/1/SUlFR0tid0kAA2vb11Ly/IGWDK+wV8TMAfV0J1Ej1J1GFRT1bssqrn6a.ttf",
"woff" : "https://f.fontdeck.com/f/1/SUlFR0tid0kAA2vb11Ly/IGWDK+wV8TMAfV0J1Ej1J1GFRT1bssqrn6a.woff",
"svg" : "https://f.fontdeck.com/f/1/SUlFR0tid0kAA2vb11Ly/IGWDK+wV8TMAfV0J1Ej1J1GFRT1bssqrn6a.svg#104"
},
"id" : 104
},
Expand All @@ -33,10 +33,10 @@ describe('modules.Fontdeck', function () {
"style" : "italic",
"weight" : "bold",
"font_urls" : {
"eot" : "http://f.fontdeck.com/f/1/azJEbTVyc1QAA11+CAE5C93+l/bAQx1ipRo6Maba19w3Yy5ng+qVWlfj.eot",
"ttf" : "http://f.fontdeck.com/f/1/azJEbTVyc1QAA11+CAE5C93+l/bAQx1ipRo6Maba19w3Yy5ng+qVWlfj.ttf",
"woff" : "http://f.fontdeck.com/f/1/azJEbTVyc1QAA11+CAE5C93+l/bAQx1ipRo6Maba19w3Yy5ng+qVWlfj.woff",
"svg" : "http://f.fontdeck.com/f/1/azJEbTVyc1QAA11+CAE5C93+l/bAQx1ipRo6Maba19w3Yy5ng+qVWlfj.svg#2256"
"eot" : "https://f.fontdeck.com/f/1/azJEbTVyc1QAA11+CAE5C93+l/bAQx1ipRo6Maba19w3Yy5ng+qVWlfj.eot",
"ttf" : "https://f.fontdeck.com/f/1/azJEbTVyc1QAA11+CAE5C93+l/bAQx1ipRo6Maba19w3Yy5ng+qVWlfj.ttf",
"woff" : "https://f.fontdeck.com/f/1/azJEbTVyc1QAA11+CAE5C93+l/bAQx1ipRo6Maba19w3Yy5ng+qVWlfj.woff",
"svg" : "https://f.fontdeck.com/f/1/azJEbTVyc1QAA11+CAE5C93+l/bAQx1ipRo6Maba19w3Yy5ng+qVWlfj.svg#2256"
},
"id" : 2256
}
Expand All @@ -54,7 +54,6 @@ describe('modules.Fontdeck', function () {
fakeDomHelper = {
loadScript: jasmine.createSpy('loadScript'),
getLoadWindow: jasmine.createSpy('getLoadWindow').andReturn(global),
getProtocol: jasmine.createSpy('getProtocol').andReturn('https:'),
getHostName: function () { return 'test-host-name'; }
};
});
Expand Down
18 changes: 9 additions & 9 deletions spec/modules/google/fontapiurlbuilder_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@ describe('modules.google.FontApiUrlBuilder', function () {
var FontApiUrlBuilder = webfont.modules.google.FontApiUrlBuilder;

it('should throw an exception if there are no font families', function () {
var builder = new FontApiUrlBuilder('http://moo', 'http:');
var builder = new FontApiUrlBuilder('https://moo');
expect(builder.build).toThrow();
});

it('should build a proper url', function () {
var builder = new FontApiUrlBuilder('http://moo', 'http:');
var builder = new FontApiUrlBuilder('https://moo');
builder.setFontFamilies(['Font1', 'Font2']);
expect(builder.build()).toEqual('http://moo?family=Font1%7CFont2');
expect(builder.build()).toEqual('https://moo?family=Font1%7CFont2');
});

it('should build a proper url', function () {
var builder = new FontApiUrlBuilder(undefined, 'http:');
var builder = new FontApiUrlBuilder(undefined);
builder.setFontFamilies(['Font1', 'Font2']);
expect(builder.build()).toEqual('http:' +
expect(builder.build()).toEqual(
FontApiUrlBuilder.DEFAULT_API_URL +
'?family=Font1%7CFont2');
});

it('should build a proper url', function () {
var builder = new FontApiUrlBuilder(undefined, 'http:');
var builder = new FontApiUrlBuilder(undefined);
builder.setFontFamilies(['Font1:bold:greek,cyrillic', 'Font2:italic', 'Font3']);
expect(builder.build()).toEqual('http:' +
expect(builder.build()).toEqual(
FontApiUrlBuilder.DEFAULT_API_URL +
'?family=Font1:bold%7CFont2:italic%7CFont3' +
'&subset=greek,cyrillic');
});

it('should build a proper url', function () {
var builder = new FontApiUrlBuilder(undefined, 'http:');
var builder = new FontApiUrlBuilder(undefined);
builder.setFontFamilies(['Font1:bold,italic:greek,cyrillic', 'Font2:italic', 'Font3::latin']);
expect(builder.build()).toEqual('http:' +
expect(builder.build()).toEqual(
FontApiUrlBuilder.DEFAULT_API_URL +
'?family=Font1:bold,italic%7CFont2:italic%7CFont3' +
'&subset=greek,cyrillic,latin');
Expand Down
13 changes: 5 additions & 8 deletions spec/modules/google/googlefontapi_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ describe('modules.google.GoogleFontApi', function () {
loadStylesheet: function (cssLink, cb) {
link = cssLink;
onload = cb;
},
getProtocol: function () {
return 'http:';
}
};

Expand Down Expand Up @@ -42,7 +39,7 @@ describe('modules.google.GoogleFontApi', function () {
});

it('has inserted the link element correctly', function () {
expect(link).toEqual('http://fonts.googleapis.com/css?family=Font1%7CFont2');
expect(link).toEqual('https://fonts.googleapis.com/css?family=Font1%7CFont2');
});

it('has the correct families', function () {
Expand All @@ -61,14 +58,14 @@ describe('modules.google.GoogleFontApi', function () {
beforeEach(function () {
loaded = false;
googleFontApi = new GoogleFontApi(fakeDomHelper, {
api: 'http://moo',
api: 'https://moo',
families: ['Font1', 'Font2']
});
googleFontApi.load(function () { loaded = true; });
});

it('has inserted the link element correctly', function () {
expect(link).toEqual('http://moo?family=Font1%7CFont2');
expect(link).toEqual('https://moo?family=Font1%7CFont2');
});

if (webfont.DomHelper.CAN_WAIT_STYLESHEET) {
Expand All @@ -91,7 +88,7 @@ describe('modules.google.GoogleFontApi', function () {
});

it('has inserted the link element correctly', function () {
expect(link).toEqual('http://fonts.googleapis.com/css?family=Font1+WithSpace%7CFont2+WithSpaceToo');
expect(link).toEqual('https://fonts.googleapis.com/css?family=Font1+WithSpace%7CFont2+WithSpaceToo');
});
});

Expand All @@ -104,7 +101,7 @@ describe('modules.google.GoogleFontApi', function () {
});

it('has inserted the link element correctly', function () {
expect(link).toEqual('http://fonts.googleapis.com/css?family=Font1+WithSpace:bi%7CFont2+WithSpaceToo:b,r');
expect(link).toEqual('https://fonts.googleapis.com/css?family=Font1+WithSpace:bi%7CFont2+WithSpaceToo:b,r');
});
});
});
7 changes: 3 additions & 4 deletions spec/modules/monotype_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('modules.Monotype', function () {

var configuration = {
projectId: '01e2ff27-25bf-4801-a23e-73d328e6c7cc',
api: 'http://fast.fonts.net/jsapidev'
api: 'https://fast.fonts.net/jsapidev'
};

var fakeDomHelper = null,
Expand All @@ -25,8 +25,7 @@ describe('modules.Monotype', function () {
script.onload = callback;
return script;
}),
getLoadWindow: jasmine.createSpy('getLoadWindow').andReturn(global),
getProtocol: jasmine.createSpy('getProtocol').andReturn('http:')
getLoadWindow: jasmine.createSpy('getLoadWindow').andReturn(global)
};
support = jasmine.createSpy('support');
load = jasmine.createSpy('load');
Expand All @@ -44,7 +43,7 @@ describe('modules.Monotype', function () {

it('should create a script element', function () {
expect(fakeDomHelper.loadScript).toHaveBeenCalled();
expect(fakeDomHelper.loadScript.calls[0].args[0]).toEqual('http://fast.fonts.net/jsapidev/01e2ff27-25bf-4801-a23e-73d328e6c7cc.js');
expect(fakeDomHelper.loadScript.calls[0].args[0]).toEqual('https://fast.fonts.net/jsapidev/01e2ff27-25bf-4801-a23e-73d328e6c7cc.js');
expect(load).toHaveBeenCalledWith([new Font('aachen bold'), new Font('kid print regular')]);
});
});
Loading