test_quicksuggest_migrate_v5.js (4801B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 // Tests Suggest prefs migration from version 4 to 5. 6 7 "use strict"; 8 9 const TO_VERSION = 5; 10 11 add_setup(async () => { 12 await setUpMigrateTest(); 13 }); 14 15 // Region=US, locale=en-US => Suggest proper is enabled. No user-branch values 16 // set before migration. 17 add_task(async function () { 18 await QuickSuggestTestUtils.withRegionAndLocale({ 19 region: "US", 20 locale: "en-US", 21 skipSuggestReset: true, 22 callback: async () => { 23 await doMigrateTest({ 24 toVersion: TO_VERSION, 25 }); 26 }, 27 }); 28 }); 29 30 // Region=US, locale=en-US => Suggest proper is enabled. The sponsored pref is 31 // false on the user branch and should keep its value after migration. 32 add_task(async function () { 33 await QuickSuggestTestUtils.withRegionAndLocale({ 34 region: "US", 35 locale: "en-US", 36 skipSuggestReset: true, 37 callback: async () => { 38 await doMigrateTest({ 39 toVersion: TO_VERSION, 40 preMigrationUserPrefs: { 41 "suggest.quicksuggest.sponsored": false, 42 }, 43 expectedPostMigrationUserPrefs: { 44 "suggest.quicksuggest.sponsored": false, 45 }, 46 }); 47 }, 48 }); 49 }); 50 51 // Region=US, locale=en-US => Suggest proper is enabled. The sponsored pref is 52 // true on the user branch and should keep its value after migration. 53 add_task(async function () { 54 await QuickSuggestTestUtils.withRegionAndLocale({ 55 region: "US", 56 locale: "en-US", 57 skipSuggestReset: true, 58 callback: async () => { 59 await doMigrateTest({ 60 toVersion: TO_VERSION, 61 preMigrationUserPrefs: { 62 "suggest.quicksuggest.sponsored": true, 63 }, 64 expectedPostMigrationUserPrefs: { 65 "suggest.quicksuggest.sponsored": true, 66 }, 67 }); 68 }, 69 }); 70 }); 71 72 // Region=DE, locale=de => Suggest proper is enabled. No user-branch values set 73 // before migration. 74 add_task(async function () { 75 await QuickSuggestTestUtils.withRegionAndLocale({ 76 region: "DE", 77 locale: "de", 78 skipSuggestReset: true, 79 callback: async () => { 80 await doMigrateTest({ 81 toVersion: TO_VERSION, 82 }); 83 }, 84 }); 85 }); 86 87 // Region=DE, locale=de => Suggest proper is enabled. The sponsored pref is 88 // false on the user branch and should keep its value after migration. 89 add_task(async function () { 90 await QuickSuggestTestUtils.withRegionAndLocale({ 91 region: "DE", 92 locale: "de", 93 skipSuggestReset: true, 94 callback: async () => { 95 await doMigrateTest({ 96 toVersion: TO_VERSION, 97 preMigrationUserPrefs: { 98 "suggest.quicksuggest.sponsored": false, 99 }, 100 expectedPostMigrationUserPrefs: { 101 "suggest.quicksuggest.sponsored": false, 102 }, 103 }); 104 }, 105 }); 106 }); 107 108 // Region=DE, locale=de => Suggest proper is enabled. The sponsored pref is 109 // true on the user branch and should keep its value after migration. 110 add_task(async function () { 111 await QuickSuggestTestUtils.withRegionAndLocale({ 112 region: "DE", 113 locale: "de", 114 skipSuggestReset: true, 115 callback: async () => { 116 await doMigrateTest({ 117 toVersion: TO_VERSION, 118 preMigrationUserPrefs: { 119 "suggest.quicksuggest.sponsored": true, 120 }, 121 expectedPostMigrationUserPrefs: { 122 "suggest.quicksuggest.sponsored": true, 123 }, 124 }); 125 }, 126 }); 127 }); 128 129 // Region=DE, locale=en-US => Suggest proper is *not* enabled as of this 130 // migration version. The sponsored pref is false on the user branch and should 131 // be cleared after migration. 132 add_task(async function () { 133 await QuickSuggestTestUtils.withRegionAndLocale({ 134 region: "DE", 135 locale: "en-US", 136 skipSuggestReset: true, 137 callback: async () => { 138 await doMigrateTest({ 139 toVersion: TO_VERSION, 140 preMigrationUserPrefs: { 141 "suggest.quicksuggest.sponsored": false, 142 }, 143 expectedPostMigrationUserPrefs: { 144 "suggest.quicksuggest.sponsored": null, 145 }, 146 }); 147 }, 148 }); 149 }); 150 151 // Region=DE, locale=en-US => Suggest proper is *not* enabled as of this 152 // migration version. The sponsored pref is true on the user branch and should 153 // be cleared after migration. 154 add_task(async function () { 155 await QuickSuggestTestUtils.withRegionAndLocale({ 156 region: "DE", 157 locale: "en-US", 158 skipSuggestReset: true, 159 callback: async () => { 160 await doMigrateTest({ 161 toVersion: TO_VERSION, 162 preMigrationUserPrefs: { 163 "suggest.quicksuggest.sponsored": true, 164 }, 165 expectedPostMigrationUserPrefs: { 166 "suggest.quicksuggest.sponsored": null, 167 }, 168 }); 169 }, 170 }); 171 });