Title: [139471] trunk/Tools
Revision
139471
Author
[email protected]
Date
2013-01-11 11:39:34 -0800 (Fri, 11 Jan 2013)

Log Message

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:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (139470 => 139471)


--- trunk/Tools/ChangeLog	2013-01-11 19:35:31 UTC (rev 139470)
+++ trunk/Tools/ChangeLog	2013-01-11 19:39:34 UTC (rev 139471)
@@ -1,3 +1,24 @@
+2013-01-11  Julie Parent  <[email protected]>
+
+        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  <[email protected]>
 
         Try CRLF to LF change in r139407 again.

Modified: trunk/Tools/TestResultServer/static-dashboards/dashboard_base.js (139470 => 139471)


--- trunk/Tools/TestResultServer/static-dashboards/dashboard_base.js	2013-01-11 19:35:31 UTC (rev 139470)
+++ trunk/Tools/TestResultServer/static-dashboards/dashboard_base.js	2013-01-11 19:39:34 UTC (rev 139471)
@@ -500,8 +500,6 @@
 
 function resourceLoadingComplete(errorMsgs)
 {
-    g_resourceLoader = null;
-    
     if (errorMsgs)
         addError(errorMsgs)
 
@@ -510,7 +508,7 @@
 
 function handleLocationChange()
 {
-    if (g_resourceLoader)
+    if (!g_resourceLoader.isLoadingComplete())
         return;
 
     if (parseParameters())

Modified: trunk/Tools/TestResultServer/static-dashboards/loader.js (139470 => 139471)


--- trunk/Tools/TestResultServer/static-dashboards/loader.js	2013-01-11 19:35:31 UTC (rev 139470)
+++ trunk/Tools/TestResultServer/static-dashboards/loader.js	2013-01-11 19:39:34 UTC (rev 139471)
@@ -67,6 +67,7 @@
 
     this._buildersThatFailedToLoad = [];
     this._staleBuilders = [];
+    this._loadingComplete = false;
 }
 
 loader.Loader.prototype = {
@@ -74,10 +75,18 @@
     {
         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;
         }

Modified: trunk/Tools/TestResultServer/static-dashboards/loader_unittests.js (139470 => 139471)


--- trunk/Tools/TestResultServer/static-dashboards/loader_unittests.js	2013-01-11 19:35:31 UTC (rev 139470)
+++ trunk/Tools/TestResultServer/static-dashboards/loader_unittests.js	2013-01-11 19:39:34 UTC (rev 139471)
@@ -153,4 +153,14 @@
     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
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to