mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
ajaxlib MDL-16693 Fixed fringe condition in ajaxlib and added test
This commit is contained in:
parent
6dbcaceef1
commit
d76b8a2068
@ -119,7 +119,8 @@ class page_requirements_manager {
|
||||
public function js($jsfile, $fullurl = false) {
|
||||
global $CFG;
|
||||
if (!$fullurl) {
|
||||
if (!file_exists($CFG->dirroot . '/' . $jsfile)) {
|
||||
// strtok is used to trim off any GET string arguments before looking for the file
|
||||
if (!file_exists($CFG->dirroot . '/' . strtok($jsfile, '?'))) {
|
||||
throw new coding_exception('Attept to require a JavaScript file that does not exist.', $jsfile);
|
||||
}
|
||||
$url = $CFG->httpswwwroot . '/' . $jsfile;
|
||||
|
@ -320,6 +320,15 @@ class page_requirements_manager_test extends ajaxlib_unit_test_base {
|
||||
$this->assertContains($html, $CFG->httpswwwroot . '/' . $jsfile);
|
||||
}
|
||||
|
||||
public function test_requiring_js_with_argument() {
|
||||
global $CFG;
|
||||
$jsfile = 'lib/javascript-static.js?d=434'; // Just needs to be a JS file that exists.
|
||||
$this->requires->js($jsfile);
|
||||
|
||||
$html = $this->requires->get_end_code();
|
||||
$this->assertContains($html, $CFG->httpswwwroot . '/' . $jsfile);
|
||||
}
|
||||
|
||||
public function test_nonexistant_js_throws_exception() {
|
||||
$cssfile = 'js/file/that/does/not/exist.js';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user