-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #722 from AnalyticalGraphicsInc/fix_isCrossOriginU…
…rl_in_ie Fix isCrossOriginUrl in IE
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/*global defineSuite*/ | ||
defineSuite([ | ||
'Core/isCrossOriginUrl', | ||
'ThirdParty/Uri' | ||
], function( | ||
isCrossOriginUrl, | ||
Uri) { | ||
"use strict"; | ||
/*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/ | ||
|
||
it('returns false for relative urls', function() { | ||
expect(isCrossOriginUrl('/some/url.jpg')).toEqual(false); | ||
expect(isCrossOriginUrl('some/url.jpg')).toEqual(false); | ||
}); | ||
|
||
it('returns false for absolute urls that are not cross-origin', function() { | ||
var pageUri = new Uri(location.href); | ||
|
||
var absoluteUrl = new Uri('/some/url.jpg').resolve(pageUri).toString(); | ||
expect(isCrossOriginUrl(absoluteUrl)).toEqual(false); | ||
|
||
absoluteUrl = new Uri('some/url.jpg').resolve(pageUri).toString(); | ||
expect(isCrossOriginUrl(absoluteUrl)).toEqual(false); | ||
}); | ||
|
||
it('returns true for absolute urls that are cross-origin', function() { | ||
expect(isCrossOriginUrl('http://example.com/some/url.jpg')).toEqual(true); | ||
|
||
// a different scheme counts as cross-origin | ||
var pageUri = new Uri(location.href); | ||
pageUri.scheme = location.protocol === 'https:' ? 'http' : 'https'; | ||
|
||
var absoluteUrl = pageUri.toString(); | ||
expect(isCrossOriginUrl(absoluteUrl)).toEqual(true); | ||
|
||
// so does a different port | ||
pageUri = new Uri(location.href); | ||
pageUri.authority = location.hostname + ':' + (+location.port + 1); | ||
|
||
absoluteUrl = pageUri.toString(); | ||
expect(isCrossOriginUrl(absoluteUrl)).toEqual(true); | ||
}); | ||
}); |