-
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 #5003 from ckeditor/t/4761-2
- Loading branch information
Showing
11 changed files
with
384 additions
and
18 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
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,61 @@ | ||
/* bender-tags: editor */ | ||
|
||
( function() { | ||
'use strict'; | ||
|
||
bender.test( { | ||
'test append timestamp returns the same resource path if there is no CKEDITOR.timestamp': performTimestampTest( | ||
'', | ||
'style.css', | ||
'style.css', | ||
'Resource path was modified without timestamp in CKEDITOR' | ||
), | ||
|
||
'test append timestamp returns resource path with timestamp if there is CKEDITOR.timestamp': performTimestampTest( | ||
'cke4', | ||
'style.css', | ||
'style.css?t=cke4', | ||
'Resource path was modified without timestamp in CKEDITOR' | ||
), | ||
|
||
'test append timestamp returns the same resource path if it is a directory path': performTimestampTest( | ||
'cke4', | ||
'style/', | ||
'style/', | ||
'Resource path to directory should not be changed' | ||
), | ||
|
||
'test append timestamp to resource path, with timestamp as single URL param, does not change it': performTimestampTest( | ||
'cke4', | ||
'style.css?t=qaz1', | ||
'style.css?t=qaz1', | ||
'Resource path with timestamp was affected with new timestamp' | ||
), | ||
|
||
'test append timestamp to resource path with chained timestamp does not change it': performTimestampTest( | ||
'cke4', | ||
'style.css?q=abc&t=qaz1', | ||
'style.css?q=abc&t=qaz1', | ||
'Resource path with chained timestamp was affected with new timestamp' | ||
), | ||
|
||
'test append timestamp to resource path with URL params adds timestamp as another param': performTimestampTest( | ||
'cke4', | ||
'style.css?q=abc', | ||
'style.css?q=abc&t=cke4', | ||
'Resource path with single param has not been affected by timestamp' | ||
) | ||
} ); | ||
|
||
function performTimestampTest( timestamp, resourcePath, expected, message ) { | ||
return function() { | ||
var originalTimestamp = CKEDITOR.timestamp; | ||
CKEDITOR.timestamp = timestamp; | ||
|
||
var result = CKEDITOR.appendTimestamp( resourcePath ); | ||
|
||
CKEDITOR.timestamp = originalTimestamp; | ||
assert.areSame( expected, result, message ); | ||
}; | ||
} | ||
} )(); |
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.2, 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
Oops, something went wrong.