Fix retuning prematurely when unit testing.
This commit is contained in:
parent
d86059b811
commit
10f23175cf
@ -43,7 +43,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var $, $$, Anonymize, AutoGIF, Board, Build, Clone, Conf, Config, FileInfo, Get, ImageHover, Main, Post, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, RevealSpoilers, Sauce, Thread, ThreadUpdater, Time, UI, d, g,
|
var $, $$, Anonymize, AutoGIF, Board, Build, Clone, Conf, Config, FileInfo, Get, ImageHover, Main, Post, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, RevealSpoilers, Sauce, Thread, ThreadUpdater, Time, UI, d, g, unitTesting,
|
||||||
__hasProp = {}.hasOwnProperty,
|
__hasProp = {}.hasOwnProperty,
|
||||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||||
|
|
||||||
@ -170,7 +170,9 @@
|
|||||||
imageFit: 'fit width'
|
imageFit: 'fit width'
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!/^(boards|images|sys)\.4chan\.org$/.test(location.hostname)) {
|
unitTesting = !!window.QUnit;
|
||||||
|
|
||||||
|
if (!(/^(boards|images|sys)\.4chan\.org$/.test(location.hostname) || unitTesting)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,7 +603,7 @@
|
|||||||
$.add(d.head, script);
|
$.add(d.head, script);
|
||||||
return $.rm(script);
|
return $.rm(script);
|
||||||
},
|
},
|
||||||
unsafeWindow: window.opera ? window : unsafeWindow !== window ? unsafeWindow : (function() {
|
unsafeWindow: unitTesting || window.opera ? window : unsafeWindow !== window ? unsafeWindow : (function() {
|
||||||
var p;
|
var p;
|
||||||
p = d.createElement('p');
|
p = d.createElement('p');
|
||||||
p.setAttribute('onclick', 'return window');
|
p.setAttribute('onclick', 'return window');
|
||||||
@ -2571,8 +2573,8 @@
|
|||||||
val = Conf[key];
|
val = Conf[key];
|
||||||
Conf[key] = $.get(key, val);
|
Conf[key] = $.get(key, val);
|
||||||
}
|
}
|
||||||
if (QUnit) {
|
if (unitTesting) {
|
||||||
Main.initQUnit();
|
Main.initUnitTesting();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pathname = location.pathname.split('/');
|
pathname = location.pathname.split('/');
|
||||||
@ -2599,7 +2601,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
initQUnit: function() {
|
initUnitTesting: function() {
|
||||||
window.x = {
|
window.x = {
|
||||||
UI: UI,
|
UI: UI,
|
||||||
$: $,
|
$: $,
|
||||||
|
|||||||
@ -163,8 +163,9 @@ $.extend $,
|
|||||||
$.rm script
|
$.rm script
|
||||||
# http://mths.be/unsafewindow
|
# http://mths.be/unsafewindow
|
||||||
unsafeWindow:
|
unsafeWindow:
|
||||||
if window.opera # Opera
|
if unitTesting or # unit testing
|
||||||
window
|
window.opera # Opera
|
||||||
|
window
|
||||||
else if unsafeWindow isnt window # Firefox
|
else if unsafeWindow isnt window # Firefox
|
||||||
unsafeWindow
|
unsafeWindow
|
||||||
else # Chrome
|
else # Chrome
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
|
unitTesting = !!window.QUnit
|
||||||
|
|
||||||
# Opera doesn't support the @match metadata key,
|
# Opera doesn't support the @match metadata key,
|
||||||
# return 4chan X here if we're not on 4chan.
|
# return 4chan X here if we're not on 4chan.
|
||||||
return unless /^(boards|images|sys)\.4chan\.org$/.test location.hostname
|
return unless /^(boards|images|sys)\.4chan\.org$/.test(location.hostname) or unitTesting
|
||||||
|
|
||||||
Conf = {}
|
Conf = {}
|
||||||
d = document
|
d = document
|
||||||
|
|||||||
@ -266,8 +266,8 @@ Main =
|
|||||||
for key, val of Conf
|
for key, val of Conf
|
||||||
Conf[key] = $.get key, val
|
Conf[key] = $.get key, val
|
||||||
|
|
||||||
if QUnit
|
if unitTesting
|
||||||
Main.initQUnit()
|
Main.initUnitTesting()
|
||||||
return
|
return
|
||||||
|
|
||||||
pathname = location.pathname.split '/'
|
pathname = location.pathname.split '/'
|
||||||
@ -289,7 +289,7 @@ Main =
|
|||||||
location.href = url if url
|
location.href = url if url
|
||||||
return
|
return
|
||||||
|
|
||||||
initQUnit: ->
|
initUnitTesting: ->
|
||||||
window.x =
|
window.x =
|
||||||
# ui.coffee
|
# ui.coffee
|
||||||
UI: UI
|
UI: UI
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user