head.js (1215B)
1 /* vim: set ts=2 et sw=2 tw=80: */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 "use strict"; 7 8 let test_path = "/tests/dom/credentialmanagement/identity/tests/mochitest"; 9 10 async function setupTest(testName, idp_origin = "https://example.net") { 11 let idp_api = idp_origin + test_path; 12 ok( 13 window.location.pathname.includes(testName), 14 `Must set the right test name when setting up. Test name "${testName}" must be in URL path "${window.location.pathname}"` 15 ); 16 let fetchPromise = fetch( 17 `${idp_api}/server_manifest.sjs?set_test=${testName}` 18 ); 19 let focusPromise = SimpleTest.promiseFocus(); 20 window.open(`${idp_api}/helper_set_cookie.html`, "_blank"); 21 await focusPromise; 22 return fetchPromise; 23 } 24 25 async function clearIdentityCredentialStorage() { 26 // Clear the storage before running test 27 return SpecialPowers.spawnChrome([], () => { 28 let icStorageService = Cc[ 29 "@mozilla.org/browser/identity-credential-storage-service;1" 30 ].getService(Ci.nsIIdentityCredentialStorageService); 31 icStorageService.clear(); 32 }); 33 }