Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Bug 575767: Stop Feedback from collection data until the user has bee…

…n notified. r=dtownsend

--HG--
branch : GECKO20b1_20100628_RELBRANCH
  • Loading branch information...
commit 6bcd9de71a595e116bcf552fbdbbbdaf3b32fc14 1 parent 6660cd9
Jono S Xia authored
46 browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js
@@ -62,7 +62,7 @@ let TestPilotSetup = {
62 62 startupComplete: false,
63 63 _shortTimer: null,
64 64 _longTimer: null,
65   - _remoteExperimentLoader: null,
  65 + _remoteExperimentLoader: null, // TODO make this a lazy initializer too?
66 66 taskList: [],
67 67 version: "",
68 68
@@ -372,10 +372,16 @@ let TestPilotSetup = {
372 372 iconClass, showSubmit,
373 373 showAlwaysSubmitCheckbox,
374 374 linkText, linkUrl,
375   - isExtensionUpdate) {
  375 + isExtensionUpdate,
  376 + onCloseCallback) {
  377 + /* TODO: Refactor the arguments of this function, it's getting really
  378 + * unweildly.... maybe pass in an object, or even make a notification an
  379 + * object that you create and then call .show() on. */
  380 +
376 381 // If there are multiple windows, show notifications in the frontmost
377 382 // window.
378   - let doc = this._getFrontBrowserWindow().document;
  383 + let window = this._getFrontBrowserWindow();
  384 + let doc = window.document;
379 385 let popup = doc.getElementById("pilot-notification-popup");
380 386
381 387 let anchor;
@@ -422,14 +428,14 @@ let TestPilotSetup = {
422 428 "testpilot.notification.update"));
423 429 submitBtn.onclick = function() {
424 430 this._extensionUpdater.check(EXTENSION_ID);
425   - self._hideNotification();
  431 + self._hideNotification(window, onCloseCallback);
426 432 };
427 433 } else {
428 434 submitBtn.setAttribute("label",
429 435 this._stringBundle.GetStringFromName("testpilot.submit"));
430 436 // Functionality for submit button:
431 437 submitBtn.onclick = function() {
432   - self._hideNotification();
  438 + self._hideNotification(window, onCloseCallback);
433 439 if (showAlwaysSubmitCheckbox && alwaysSubmitCheckbox.checked) {
434 440 self._prefs.setValue(ALWAYS_SUBMIT_DATA, true);
435 441 }
@@ -464,7 +470,7 @@ let TestPilotSetup = {
464 470 } else {
465 471 self._openChromeless(linkUrl);
466 472 }
467   - self._hideNotification();
  473 + self._hideNotification(window, onCloseCallback);
468 474 }
469 475 };
470 476 link.setAttribute("hidden", false);
@@ -473,7 +479,7 @@ let TestPilotSetup = {
473 479 }
474 480
475 481 closeBtn.onclick = function() {
476   - self._hideNotification();
  482 + self._hideNotification(window, onCloseCallback);
477 483 };
478 484
479 485 // Show the popup:
@@ -487,13 +493,19 @@ let TestPilotSetup = {
487 493 window.TestPilotWindowUtils.openChromeless(url);
488 494 },
489 495
490   - _hideNotification: function TPS__hideNotification() {
491   - let window = this._getFrontBrowserWindow();
  496 + _hideNotification: function TPS__hideNotification(window, onCloseCallback) {
  497 + /* Note - we take window as an argument instead of just using the frontmost
  498 + * window because the window order might have changed since the notification
  499 + * appeared and we want to be sure we close the notification in the same
  500 + * window as we opened it in! */
492 501 let popup = window.document.getElementById("pilot-notification-popup");
493 502 popup.hidden = true;
494 503 popup.setAttribute("open", "false");
495 504 popup.removeAttribute("tpisextensionupdate");
496 505 popup.hidePopup();
  506 + if (onCloseCallback) {
  507 + onCloseCallback();
  508 + }
497 509 },
498 510
499 511 _isShowingUpdateNotification : function() {
@@ -543,11 +555,11 @@ let TestPilotSetup = {
543 555 if (this._prefs.getValue(POPUP_SHOW_ON_NEW, false)) {
544 556 for (i = 0; i < this.taskList.length; i++) {
545 557 task = this.taskList[i];
546   - if (task.status == TaskConstants.STATUS_STARTING ||
  558 + if (task.status == TaskConstants.STATUS_PENDING ||
547 559 task.status == TaskConstants.STATUS_NEW) {
548 560 if (task.taskType == TaskConstants.TYPE_EXPERIMENT) {
549 561 this._showNotification(
550   - task, true,
  562 + task, false,
551 563 this._stringBundle.formatStringFromName(
552 564 "testpilot.notification.newTestPilotStudy.message",
553 565 [task.title], 1),
@@ -555,14 +567,16 @@ let TestPilotSetup = {
555 567 "testpilot.notification.newTestPilotStudy"),
556 568 "new-study", false, false,
557 569 this._stringBundle.GetStringFromName("testpilot.moreInfo"),
558   - task.defaultUrl);
559   - // Having shown the notification, update task status so that this
560   - // notification won't be shown again.
561   - task.changeStatus(TaskConstants.STATUS_IN_PROGRESS, true);
  570 + task.defaultUrl, false, function() {
  571 + /* on close callback (Bug 575767) -- when the "new study
  572 + * starting" popup is dismissed, then the study can start. */
  573 + task.changeStatus(TaskConstants.STATUS_IN_PROGRESS, true);
  574 + TestPilotSetup.reloadRemoteExperiments();
  575 + });
562 576 return;
563 577 } else if (task.taskType == TaskConstants.TYPE_SURVEY) {
564 578 this._showNotification(
565   - task, true,
  579 + task, false,
566 580 this._stringBundle.formatStringFromName(
567 581 "testpilot.notification.newTestPilotSurvey.message",
568 582 [task.title], 1),
28 browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js
@@ -203,6 +203,7 @@ var TestPilotTask = {
203 203 },
204 204
205 205 onDetailPageOpened: function TestPilotTask_onDetailPageOpened(){
  206 + // TODO fold this into loadPage()?
206 207 },
207 208
208 209 checkDate: function TestPilotTask_checkDate() {
@@ -444,14 +445,9 @@ TestPilotExperiment.prototype = {
444 445 },
445 446
446 447 experimentIsRunning: function TestPilotExperiment_isRunning() {
447   - if (this._optInRequired) {
448   - return (this._status == TaskConstants.STATUS_STARTING ||
449   - this._status == TaskConstants.STATUS_IN_PROGRESS);
450   - } else {
451   - // Tests that don't require extra opt-in should start running even
452   - // if you haven't seen them yet.
453   - return (this._status < TaskConstants.STATUS_FINISHED);
454   - }
  448 + // bug 575767
  449 + return (this._status == TaskConstants.STATUS_STARTING ||
  450 + this._status == TaskConstants.STATUS_IN_PROGRESS);
455 451 },
456 452
457 453 // Pass events along to handlers:
@@ -599,11 +595,23 @@ TestPilotExperiment.prototype = {
599 595 }
600 596 }
601 597
602   - // No-opt-in required tests skip PENDING and go straight to STARTING.
  598 + // If the notify-on-new-study pref is turned off, and the test doesn't
  599 + // require opt-in, then it can jump straight ahead to STARTING.
603 600 if (!this._optInRequired &&
604   - this._status < TaskConstants.STATUS_STARTING &&
  601 + !Application.prefs.getValue("extensions.testpilot.popup.showOnNewStudy",
  602 + false) &&
  603 + (this._status == TaskConstants.STATUS_NEW ||
  604 + this._status == TaskConstants.STATUS_PENDING)) {
  605 + this._logger.info("Skipping pending and going straight to starting.");
  606 + this.changeStatus(TaskConstants.STATUS_STARTING, true);
  607 + }
  608 +
  609 + // If a study is STARTING, and we're in the right date range,
  610 + // then start it, and move it to IN_PROGRESS.
  611 + if ( this._status == TaskConstants.STATUS_STARTING &&
605 612 currentDate >= this._startDate &&
606 613 currentDate <= this._endDate) {
  614 + this._logger.info("Study now starting.");
607 615 let uuidGenerator =
608 616 Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
609 617 let uuid = uuidGenerator.generateUUID().toString();

0 comments on commit 6bcd9de

Please sign in to comment.
Something went wrong with that request. Please try again.