https://bugs.webkit.org/show_bug.cgi?id=106247
Old code nulled out the loader instance when it completed loading and
then later used the fact that it was null to determine if it had loaded
or not. This is not only unintuitive, but it also prevents using the
loader object later on.
Added new method, used it, added unit test for it.
Reviewed by Dirk Pranke.
* TestResultServer/static-dashboards/dashboard_base.js:
(resourceLoadingComplete):
(handleLocationChange):
* TestResultServer/static-dashboards/loader.js:
(.):
* TestResultServer/static-dashboards/loader_unittests.js:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@139471
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-01-11 Julie Parent <jparent@chromium.org>
+
+ Dashboard Cleanup: Add isLoadingComplete to the loader.Loader object.
+ https://bugs.webkit.org/show_bug.cgi?id=106247
+
+ Old code nulled out the loader instance when it completed loading and
+ then later used the fact that it was null to determine if it had loaded
+ or not. This is not only unintuitive, but it also prevents using the
+ loader object later on.
+
+ Added new method, used it, added unit test for it.
+
+ Reviewed by Dirk Pranke.
+
+ * TestResultServer/static-dashboards/dashboard_base.js:
+ (resourceLoadingComplete):
+ (handleLocationChange):
+ * TestResultServer/static-dashboards/loader.js:
+ (.):
+ * TestResultServer/static-dashboards/loader_unittests.js:
+
2013-01-11 Ryosuke Niwa <rniwa@webkit.org>
Try CRLF to LF change in r139407 again.
function resourceLoadingComplete(errorMsgs)
{
- g_resourceLoader = null;
-
if (errorMsgs)
addError(errorMsgs)
function handleLocationChange()
{
- if (g_resourceLoader)
+ if (!g_resourceLoader.isLoadingComplete())
return;
if (parseParameters())
this._buildersThatFailedToLoad = [];
this._staleBuilders = [];
+ this._loadingComplete = false;
}
loader.Loader.prototype = {
{
this._loadNext();
},
+ isLoadingComplete: function()
+ {
+ return this._loadingComplete;
+ },
_loadNext: function()
{
var loadingStep = this._loadingSteps.shift();
if (!loadingStep) {
+ this._loadingComplete = true;
+ // FIXME(jparent): Loader should not know about global
+ // functions, should use a callback or dispatch load
+ // event instead.
resourceLoadingComplete(this._getLoadingErrorMessages());
return;
}
resourceLoader._buildersThatFailedToLoad = ['builder1', 'builder2'];
resourceLoader._staleBuilders = ['staleBuilder1'];
equal(resourceLoader._getLoadingErrorMessages(), 'ERROR: Failed to get data from builder1,builder2.<br>ERROR: Data from staleBuilder1 is more than 1 day stale.<br>');
+});
+
+test('Loaded state set', 2, function() {
+ resetGlobals();
+
+ var resourceLoader = new loader.Loader();
+ equal(false, resourceLoader.isLoadingComplete(), 'Before loading, loading is not complete');
+ resourceLoader._loadingSteps = [];
+ resourceLoader.load();
+ equal(true, resourceLoader.isLoadingComplete(), 'After loading, loading is complete');
});
\ No newline at end of file