Skip to content

Commit

Permalink
Merge remote branch 'origin/safin/yepnope-issue'
Browse files Browse the repository at this point in the history
  • Loading branch information
vlizard committed Dec 30, 2014
2 parents f25aa1f + 554f568 commit e53ecd4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/third-party/yepnope/yepnope.1.5.4.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var docElement = doc.documentElement,
return toString.call( fn ) == "[object Function]";
},
readFirstScript = function() {
if (!firstScript || !firstScript.parentNode) {
if (!firstScript || !firstScript.parentNode || !docElement.contains(firstScript)) {
firstScript = doc.getElementsByTagName( "script" )[ 0 ];
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// this script is executed in iframe so it won't spoil test page global namespace
window.firstScriptContainerRemoved = true;
31 changes: 29 additions & 2 deletions tests/unit/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,37 @@ Echo.Tests.asyncTest("yepnope corner cases", function() {
"src": "{%=baseURLs.sdk%}/loader.js"
});
});
QUnit.expect(4);
var removingFirstNodeParent = Echo.Tests.isolate(function(callback) {
// Steps (all in iframe):
// 1. wrap script in a div container and append one to the HEAD element
// 2. append "loader" script to the BODY element
// 3. once it's loaded, remove first script container
// 4. try to download something
var frame = this;
var container = $("<div>");
var script = $("<script>");
container.append(script).appendTo(this.document.body);
$("<script>").on("load readystatechange", function() {
$(this).off("load readystatechange");
container.remove();
frame.Echo.Loader.download([{
"url": Echo.Tests.baseURL +
"fixtures/resources/loader/check-removing-first-script-container.js"
}], function() {
QUnit.ok(frame.firstScriptContainerRemoved,
"Check if removing of firstNode's parent doesn't cause side effects");
callback();
});
}).appendTo(this.document.body).attr({
"type": "text/javascript",
"src": "{%=baseURLs.sdk%}/loader.js"
});
});
QUnit.expect(5);
Echo.Utils.sequentialCall([
raceConditions,
removingFirstNode
removingFirstNode,
removingFirstNodeParent
], function() {
QUnit.start();
});
Expand Down

0 comments on commit e53ecd4

Please sign in to comment.