From 8388e1044aa78afee9ce6e7e9889975b218f5936 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Mon, 3 Oct 2016 14:09:52 -0700 Subject: [PATCH] cleanup to use script-driven cache cleaning --- .../tests/performance/domain-check.js | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/scripts/developer/tests/performance/domain-check.js b/scripts/developer/tests/performance/domain-check.js index 67da45e1b6..1a42683d92 100644 --- a/scripts/developer/tests/performance/domain-check.js +++ b/scripts/developer/tests/performance/domain-check.js @@ -25,10 +25,13 @@ function debug() { print.apply(null, [].concat.apply(['hrs fixme', version], [].map.call(arguments, JSON.stringify))); } -var emptyishPlace = 'empty'; -var cachePlaces = ['localhost', 'Welcome']; -var isInCachePlace = cachePlaces.indexOf(location.hostname) >= 0; -var defaultPlace = isInCachePlace ? 'Playa' : location.hostname; +function isNowIn(place) { // true if currently in specified place + return location.hostname.toLowerCase() === place.toLowerCase(); +} + +var cachePlaces = ['dev-Welcome', 'localhost']; // For now, list the lighter weight one first. +var isInCachePlace = cachePlaces.some(isNowIn); +var defaultPlace = isInCachePlace ? 'dev-Playa' : location.hostname; var prompt = "domain-check.js version " + version + "\n\nWhat place should we enter?"; debug(cachePlaces, isInCachePlace, defaultPlace, prompt); var entryPlace = Window.prompt(prompt, defaultPlace); @@ -114,17 +117,9 @@ function doLoad(place, continuationWithLoadTime) { // Go to place and call conti } }; - function doit() { - debug('go', place); - location.hostChanged.connect(waitForLoad); - location.handleLookupString(place); - } - if (location.placename.toLowerCase() === place.toLowerCase()) { - location.handleLookupString(emptyishPlace); - Script.setTimeout(doit, 1000); - } else { - doit(); - } + debug('go', place); + location.hostChanged.connect(waitForLoad); + location.handleLookupString(place); } var config = Render.getConfig("Stats"); @@ -144,6 +139,7 @@ function doRender(continuation) { }); } +var TELEPORT_PAUSE = 500; function maybePrepareCache(continuation) { var prepareCache = Window.confirm("Prepare cache?\n\n\ Should we start with all and only those items cached that are encountered when visiting:\n" + cachePlaces.join(', ') + "\n\ @@ -151,8 +147,6 @@ If 'yes', cache will be cleared and we will visit these two, with a turn in each You would want to say 'no' (and make other preparations) if you were testing these places."); if (prepareCache) { - location.handleLookupString(emptyishPlace); - Window.alert("Please do menu Edit->Reload Content (Clears all caches) and THEN press 'ok'."); function loadNext() { var place = cachePlaces.shift(); doLoad(place, function (prepTime) { @@ -164,9 +158,12 @@ You would want to say 'no' (and make other preparations) if you were testing the } }); } - loadNext(); + location.handleLookupString(cachePlaces[cachePlaces.length - 1]); + Menu.triggerOption("Reload Content (Clears all caches)"); + Script.setTimeout(loadNext, TELEPORT_PAUSE); } else { - continuation(); + location.handleLookupString(isNowIn(cachePlaces[0]) ? cachePlaces[1] : cachePlaces[0]); + Script.setTimeout(continuation, TELEPORT_PAUSE); } }