-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 #4852 from ckeditor/t/4761
Fix for lack of cache key for some resources
- Loading branch information
Showing
9 changed files
with
299 additions
and
7 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
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
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,157 @@ | ||
/* bender-tags: editor */ | ||
|
||
( function() { | ||
'use strict'; | ||
|
||
var FAKE_BASE_PATH = 'http://some.example:1030/subdir/ckeditor/', | ||
testCases = [ | ||
{ | ||
url: 'just.js', | ||
expected: FAKE_BASE_PATH + 'just.js', | ||
timestamp: '' | ||
}, | ||
|
||
{ | ||
url: 'just.js', | ||
expected: FAKE_BASE_PATH + 'just.js?t=347', | ||
timestamp: '347' | ||
}, | ||
|
||
{ | ||
url: './test.css', | ||
expected: FAKE_BASE_PATH + './test.css', | ||
timestamp: '' | ||
}, | ||
|
||
{ | ||
url: './test.css', | ||
expected: FAKE_BASE_PATH + './test.css?t=tr4', | ||
timestamp: 'tr4' | ||
}, | ||
|
||
{ | ||
url: '../whatever.js', | ||
expected: FAKE_BASE_PATH + '../whatever.js', | ||
timestamp: '' | ||
}, | ||
|
||
{ | ||
url: '../whatever.js', | ||
expected: FAKE_BASE_PATH + '../whatever.js?t=qwerty', | ||
timestamp: 'qwerty' | ||
}, | ||
|
||
{ | ||
url: '/file', | ||
expected: '/file', | ||
timestamp: '' | ||
}, | ||
|
||
{ | ||
url: '/file', | ||
expected: '/file?t=cke4', | ||
timestamp: 'cke4' | ||
}, | ||
|
||
{ | ||
url: 'http://some.site:47/file.js', | ||
expected: 'http://some.site:47/file.js', | ||
timestamp: '' | ||
}, | ||
|
||
{ | ||
url: 'http://some.site:47/file.js', | ||
expected: 'http://some.site:47/file.js?t=cv3', | ||
timestamp: 'cv3' | ||
}, | ||
|
||
{ | ||
url: 'https://whatever/file', | ||
expected: 'https://whatever/file', | ||
timestamp: '' | ||
}, | ||
|
||
{ | ||
url: 'https://whatever/file', | ||
expected: 'https://whatever/file?t=1er', | ||
timestamp: '1er' | ||
}, | ||
|
||
{ | ||
url: '//cksource.com/file.css', | ||
expected: '//cksource.com/file.css', | ||
timestamp: '' | ||
}, | ||
|
||
{ | ||
url: '//cksource.com/file.css', | ||
expected: '//cksource.com/file.css?t=try6', | ||
timestamp: 'try6' | ||
}, | ||
|
||
{ | ||
url: 'file.t?something=here', | ||
expected: FAKE_BASE_PATH + 'file.t?something=here&t=wer', | ||
timestamp: 'wer' | ||
}, | ||
|
||
{ | ||
url: '/file.t?something=here', | ||
expected: '/file.t?something=here&t=wer', | ||
timestamp: 'wer' | ||
}, | ||
|
||
{ | ||
url: 'http://dot.example/file.t?something=here', | ||
expected: 'http://dot.example/file.t?something=here&t=wer', | ||
timestamp: 'wer' | ||
}, | ||
|
||
{ | ||
url: 'https://dot.example/file.t?something=here', | ||
expected: 'https://dot.example/file.t?something=here&t=wer', | ||
timestamp: 'wer' | ||
}, | ||
|
||
{ | ||
url: '//dot.example/file.t?something=here', | ||
expected: '//dot.example/file.t?something=here&t=wer', | ||
timestamp: 'wer' | ||
} | ||
], | ||
tests = createGetUrlTests( testCases ); | ||
|
||
bender.test( tests ); | ||
|
||
function createGetUrlTests( testCases ) { | ||
return CKEDITOR.tools.array.reduce( testCases, function( tests, testCase ) { | ||
var test = {}, | ||
testName = 'test CKEDITOR.getUrl( \'' + testCase.url + '\' ) with timestamp \'' + | ||
testCase.timestamp + '\''; | ||
|
||
test[ testName ] = createTest( testCase ); | ||
|
||
return CKEDITOR.tools.object.merge( tests, test ); | ||
}, {} ); | ||
|
||
function createTest( options ) { | ||
var url = options.url, | ||
expected = options.expected, | ||
timestamp = options.timestamp; | ||
|
||
return function() { | ||
var originalBasePath = CKEDITOR.basePath, | ||
originalTimestamp = CKEDITOR.timestamp, | ||
actualResult; | ||
|
||
CKEDITOR.basePath = FAKE_BASE_PATH; | ||
CKEDITOR.timestamp = timestamp; | ||
actualResult = CKEDITOR.getUrl( url ); | ||
CKEDITOR.basePath = originalBasePath; | ||
CKEDITOR.timestamp = originalTimestamp; | ||
|
||
assert.areSame( expected, actualResult, 'Invalid URL generated from the ' + url ); | ||
}; | ||
} | ||
} | ||
} )(); |
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,13 @@ | ||
<div id="editor"> | ||
<p>Lorem ipsum dolor sit amet</p> | ||
</div> | ||
|
||
<script> | ||
( function() { | ||
if ( bender.tools.env.mobile || !CKEDITOR.timestamp ) { | ||
return bender.ignore(); | ||
} | ||
|
||
CKEDITOR.replace( 'editor' ); | ||
} )(); | ||
</script> |
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,10 @@ | ||
@bender-tags: bug, 4.17.0, 4761 | ||
@bender-ui: collapsed | ||
@bender-ckeditor-plugins: wysiwygarea, toolbar, undo, emoji, copyformatting, easyimage, tableselection | ||
|
||
**Note**: This test requires CKEDITOR with set `CKEDITOR.timestamp` (e.g. built one). | ||
|
||
1. Open developer tools and switch to "Network" tab. | ||
2. Refresh the page. | ||
|
||
**Expected** CKEditor 4's resources are loaded with the cache key (`?t=<some alphanum characters>` at the end of URL). |
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