How to use run_next_test method in wpt

Best JavaScript code snippet using wpt

test_localeService.js

Source:test_localeService.js Github

copy

Full Screen

...11 */12add_test(function test_defaultLocale() {13 const defaultLocale = localeService.defaultLocale;14 Assert.ok(defaultLocale.length !== 0, "Default locale is not empty");15 run_next_test();16});17add_test(function test_lastFallbackLocale() {18 const lastFallbackLocale = localeService.lastFallbackLocale;19 Assert.ok(lastFallbackLocale === "en-US", "Last fallback locale is en-US");20 run_next_test();21});22add_test(function test_appLocalesAsLangTags() {23 const appLocale = localeService.appLocaleAsLangTag;24 Assert.ok(appLocale != "", "appLocale is non-empty");25 const appLocales = localeService.appLocalesAsLangTags;26 Assert.ok(Array.isArray(appLocales), "appLocales returns an array");27 Assert.ok(28 appLocale == appLocales[0],29 "appLocale matches first entry in appLocales"30 );31 const enUSLocales = appLocales.filter(loc => loc === "en-US");32 Assert.ok(enUSLocales.length == 1, "en-US is present exactly one time");33 run_next_test();34});35const PREF_REQUESTED_LOCALES = "intl.locale.requested";36const REQ_LOC_CHANGE_EVENT = "intl:requested-locales-changed";37add_test(function test_requestedLocales() {38 const requestedLocales = localeService.requestedLocales;39 Assert.ok(40 Array.isArray(requestedLocales),41 "requestedLocales returns an array"42 );43 run_next_test();44});45/**46 * In this test we verify that after we set an observer on the LocaleService47 * event for requested locales change, it will be fired when the48 * pref for matchOS is set to true.49 *50 * Then, we test that when the matchOS is set to true, we will retrieve51 * OS locale from requestedLocales.52 */53add_test(function test_requestedLocales_matchOS() {54 do_test_pending();55 Services.prefs.setCharPref(PREF_REQUESTED_LOCALES, "ar-IR");56 const observer = {57 observe(aSubject, aTopic, aData) {58 switch (aTopic) {59 case REQ_LOC_CHANGE_EVENT:60 const reqLocs = localeService.requestedLocales;61 Assert.ok(reqLocs[0] === osPrefs.systemLocale);62 Services.obs.removeObserver(observer, REQ_LOC_CHANGE_EVENT);63 do_test_finished();64 }65 },66 };67 Services.obs.addObserver(observer, REQ_LOC_CHANGE_EVENT);68 Services.prefs.setCharPref(PREF_REQUESTED_LOCALES, "");69 run_next_test();70});71/**72 * In this test we verify that after we set an observer on the LocaleService73 * event for requested locales change, it will be fired when the74 * pref for browser UI locale changes.75 */76add_test(function test_requestedLocales_onChange() {77 do_test_pending();78 Services.prefs.setCharPref(PREF_REQUESTED_LOCALES, "ar-IR");79 const observer = {80 observe(aSubject, aTopic, aData) {81 switch (aTopic) {82 case REQ_LOC_CHANGE_EVENT:83 const reqLocs = localeService.requestedLocales;84 Assert.ok(reqLocs[0] === "sr-RU");85 Services.obs.removeObserver(observer, REQ_LOC_CHANGE_EVENT);86 do_test_finished();87 }88 },89 };90 Services.obs.addObserver(observer, REQ_LOC_CHANGE_EVENT);91 Services.prefs.setCharPref(PREF_REQUESTED_LOCALES, "sr-RU");92 run_next_test();93});94add_test(function test_requestedLocale() {95 Services.prefs.setCharPref(PREF_REQUESTED_LOCALES, "tlh");96 let requestedLocale = localeService.requestedLocale;97 Assert.ok(98 requestedLocale === "tlh",99 "requestedLocale returns the right value"100 );101 Services.prefs.clearUserPref(PREF_REQUESTED_LOCALES);102 run_next_test();103});104add_test(function test_requestedLocales() {105 localeService.requestedLocales = ["de-AT", "de-DE", "de-CH"];106 let locales = localeService.requestedLocales;107 Assert.ok(locales[0] === "de-AT");108 Assert.ok(locales[1] === "de-DE");109 Assert.ok(locales[2] === "de-CH");110 run_next_test();111});112add_test(function test_isAppLocaleRTL() {113 Assert.ok(typeof localeService.isAppLocaleRTL === "boolean");114 run_next_test();115});116add_test(function test_isAppLocaleRTL_pseudo() {117 let avLocales = localeService.availableLocales;118 let reqLocales = localeService.requestedLocales;119 localeService.availableLocales = ["en-US"];120 localeService.requestedLocales = ["en-US"];121 Services.prefs.setCharPref("intl.l10n.pseudo", "");122 Assert.ok(localeService.isAppLocaleRTL === false);123 Services.prefs.setCharPref("intl.l10n.pseudo", "bidi");124 Assert.ok(localeService.isAppLocaleRTL === true);125 Services.prefs.setCharPref("intl.l10n.pseudo", "accented");126 Assert.ok(localeService.isAppLocaleRTL === false);127 // Clean up128 localeService.availableLocales = avLocales;129 localeService.requestedLocales = reqLocales;130 Services.prefs.clearUserPref("intl.l10n.pseudo");131 run_next_test();132});133add_test(function test_packagedLocales() {134 const locales = localeService.packagedLocales;135 Assert.ok(locales.length !== 0, "Packaged locales are empty");136 run_next_test();137});138add_test(function test_availableLocales() {139 const avLocales = localeService.availableLocales;140 localeService.availableLocales = ["und", "ar-IR"];141 let locales = localeService.availableLocales;142 Assert.ok(locales.length == 2);143 Assert.ok(locales[0] === "und");144 Assert.ok(locales[1] === "ar-IR");145 localeService.availableLocales = avLocales;146 run_next_test();147});148/**149 * This test verifies that all values coming from the pref are sanitized.150 */151add_test(function test_requestedLocales_sanitize() {152 Services.prefs.setStringPref(153 PREF_REQUESTED_LOCALES,154 "de,2,#$@#,pl,ąó,!a2,DE-at,,;"155 );156 let locales = localeService.requestedLocales;157 Assert.equal(locales[0], "de");158 Assert.equal(locales[1], "pl");159 Assert.equal(locales[2], "de-AT");160 Assert.equal(locales.length, 3);161 Services.prefs.clearUserPref(PREF_REQUESTED_LOCALES);162 run_next_test();163});164add_test(function test_handle_ja_JP_mac() {165 const bkpAvLocales = localeService.availableLocales;166 localeService.availableLocales = ["ja-JP-mac", "en-US"];167 localeService.requestedLocales = ["ja-JP-mac"];168 let reqLocales = localeService.requestedLocales;169 Assert.equal(reqLocales[0], "ja-JP-macos");170 let avLocales = localeService.availableLocales;171 Assert.equal(avLocales[0], "ja-JP-macos");172 let appLocales = localeService.appLocalesAsBCP47;173 Assert.equal(appLocales[0], "ja-JP-macos");174 let appLocalesAsLT = localeService.appLocalesAsLangTags;175 Assert.equal(appLocalesAsLT[0], "ja-JP-mac");176 Assert.equal(localeService.appLocaleAsLangTag, "ja-JP-mac");177 localeService.availableLocales = bkpAvLocales;178 run_next_test();179});180registerCleanupFunction(() => {181 Services.prefs.clearUserPref(PREF_REQUESTED_LOCALES);...

Full Screen

Full Screen

test_xpcomutils.js

Source:test_xpcomutils.js Github

copy

Full Screen

...32 try {33 x.QueryInterface(Components.interfaces.nsIDOMDocument);34 do_throw("QI should not have succeeded!");35 } catch(e) {}36 run_next_test();37});38add_test(function test_generateCI()39{40 const classID = Components.ID("562dae2e-7cff-432b-995b-3d4c03fa2b89");41 const classDescription = "generateCI test component";42 const flags = Components.interfaces.nsIClassInfo.DOM_OBJECT;43 var x = {44 QueryInterface: XPCOMUtils.generateQI([]),45 classInfo: XPCOMUtils.generateCI({classID: classID,46 interfaces: [],47 flags: flags,48 classDescription: classDescription})49 };50 try {51 var ci = x.QueryInterface(Components.interfaces.nsIClassInfo);52 ci = ci.QueryInterface(Components.interfaces.nsISupports);53 ci = ci.QueryInterface(Components.interfaces.nsIClassInfo);54 do_check_eq(ci.classID, classID);55 do_check_eq(ci.flags, flags);56 do_check_eq(ci.classDescription, classDescription);57 } catch(e) {58 do_throw("Classinfo for x should not be missing or broken");59 }60 run_next_test();61});62add_test(function test_defineLazyGetter()63{64 let accessCount = 0;65 let obj = {66 inScope: false67 };68 const TEST_VALUE = "test value";69 XPCOMUtils.defineLazyGetter(obj, "foo", function() {70 accessCount++;71 this.inScope = true;72 return TEST_VALUE;73 });74 do_check_eq(accessCount, 0);75 // Get the property, making sure the access count has increased.76 do_check_eq(obj.foo, TEST_VALUE);77 do_check_eq(accessCount, 1);78 do_check_true(obj.inScope);79 // Get the property once more, making sure the access count has not80 // increased.81 do_check_eq(obj.foo, TEST_VALUE);82 do_check_eq(accessCount, 1);83 run_next_test();84});85add_test(function test_defineLazyServiceGetter()86{87 let obj = { };88 XPCOMUtils.defineLazyServiceGetter(obj, "service",89 "@mozilla.org/consoleservice;1",90 "nsIConsoleService");91 let service = Cc["@mozilla.org/consoleservice;1"].92 getService(Ci.nsIConsoleService);93 // Check that the lazy service getter and the actual service have the same94 // properties.95 for (let prop in obj.service)96 do_check_true(prop in service);97 for (let prop in service)98 do_check_true(prop in obj.service);99 run_next_test();100});101add_test(function test_categoryRegistration()102{103 const CATEGORY_NAME = "test-cat";104 const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";105 const XULAPPINFO_CID = Components.ID("{fc937916-656b-4fb3-a395-8c63569e27a8}");106 // Create a fake app entry for our category registration apps filter.107 let XULAppInfo = {108 vendor: "Mozilla",109 name: "catRegTest",110 ID: "{adb42a9a-0d19-4849-bf4d-627614ca19be}",111 version: "1",112 appBuildID: "2007010101",113 platformVersion: "",114 platformBuildID: "2007010101",115 inSafeMode: false,116 logConsoleErrors: true,117 OS: "XPCShell",118 XPCOMABI: "noarch-spidermonkey",119 QueryInterface: XPCOMUtils.generateQI([120 Ci.nsIXULAppInfo,121 Ci.nsIXULRuntime,122 ])123 };124 let XULAppInfoFactory = {125 createInstance: function (outer, iid) {126 if (outer != null)127 throw Cr.NS_ERROR_NO_AGGREGATION;128 return XULAppInfo.QueryInterface(iid);129 }130 };131 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);132 registrar.registerFactory(133 XULAPPINFO_CID,134 "XULAppInfo",135 XULAPPINFO_CONTRACTID,136 XULAppInfoFactory137 );138 // Load test components.139 do_load_manifest("CatRegistrationComponents.manifest");140 const EXPECTED_ENTRIES = ["CatAppRegisteredComponent",141 "CatRegisteredComponent"];142 // Check who is registered in "test-cat" category.143 let foundEntriesCount = 0;144 let catMan = Cc["@mozilla.org/categorymanager;1"].145 getService(Ci.nsICategoryManager);146 let entries = catMan.enumerateCategory(CATEGORY_NAME);147 while (entries.hasMoreElements()) {148 foundEntriesCount++;149 let entry = entries.getNext().QueryInterface(Ci.nsISupportsCString).data;150 print("Check the found category entry (" + entry + ") is expected."); 151 do_check_true(EXPECTED_ENTRIES.indexOf(entry) != -1);152 }153 print("Check there are no more or less than expected entries.");154 do_check_eq(foundEntriesCount, EXPECTED_ENTRIES.length);155 run_next_test();156});157add_test(function test_generateSingletonFactory()158{159 const XPCCOMPONENT_CONTRACTID = "@mozilla.org/singletonComponentTest;1";160 const XPCCOMPONENT_CID = Components.ID("{31031c36-5e29-4dd9-9045-333a5d719a3e}");161 function XPCComponent() {}162 XPCComponent.prototype = {163 classID: XPCCOMPONENT_CID,164 _xpcom_factory: XPCOMUtils.generateSingletonFactory(XPCComponent),165 QueryInterface: XPCOMUtils.generateQI([])166 };167 let NSGetFactory = XPCOMUtils.generateNSGetFactory([XPCComponent]);168 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);169 registrar.registerFactory(170 XPCCOMPONENT_CID,171 "XPCComponent",172 XPCCOMPONENT_CONTRACTID,173 NSGetFactory(XPCCOMPONENT_CID)174 );175 // First, try to instance the component.176 let instance = Cc[XPCCOMPONENT_CONTRACTID].createInstance(Ci.nsISupports);177 // Try again, check that it returns the same instance as before.178 do_check_eq(instance,179 Cc[XPCCOMPONENT_CONTRACTID].createInstance(Ci.nsISupports));180 // Now, for sanity, check that getService is also returning the same instance.181 do_check_eq(instance,182 Cc[XPCCOMPONENT_CONTRACTID].getService(Ci.nsISupports));183 run_next_test();184});185////////////////////////////////////////////////////////////////////////////////186//// Test Runner187function run_test()188{189 run_next_test();...

Full Screen

Full Screen

test_keyvaluestore.js

Source:test_keyvaluestore.js Github

copy

Full Screen

...27let gTests = [];28gTests.push(function test_getAll_noData() {29 SecureKeyValueStore.getAll(function(data) {30 do_check_eq(data, null);31 run_next_test();32 });33});34gTests.push(function test_get_noData() {35 const nonexistentKey = "nonexistentKey";36 SecureKeyValueStore.get(nonexistentKey, function(value) {37 do_check_eq(value, null);38 run_next_test();39 });40});41const testdata = {42 somekey: "somevalue",43 anotherkey: "another value"44};45gTests.push(function test_set_noData() {46 onKeyChangedObserved(function(info) {47 do_check_eq(info.key, "somekey");48 do_check_eq(info.value, testdata.somekey);49 run_next_test();50 });51 SecureKeyValueStore.set("somekey", testdata.somekey);52});53gTests.push(function test_get_withData() {54 SecureKeyValueStore.get("somekey", function(value) {55 do_check_eq(value, testdata.somekey);56 run_next_test();57 });58});59gTests.push(function test_set_another() {60 onKeyChangedObserved(function(info) {61 do_check_eq(info.key, "anotherkey");62 do_check_eq(info.value, testdata.anotherkey);63 run_next_test();64 });65 SecureKeyValueStore.set("anotherkey", testdata.anotherkey);66});67gTests.push(function test_getAll() {68 SecureKeyValueStore.getAll(function(data) {69 let expectedkeys = Object.keys(testdata).sort();70 let keys = Object.keys(data).sort();71 do_check_eq(keys.length, expectedkeys.length);72 for (let i = 0; i < keys.length; i++) {73 do_check_eq(keys[i], expectedkeys[i]);74 do_check_eq(data[keys[i]], testdata[keys[i]]);75 }76 run_next_test();77 });78});79gTests.push(function test_remove() {80 onKeyChangedObserved(function(info) {81 do_check_eq(info.key, "somekey");82 do_check_eq(info.value, null);83 run_next_test();84 });85 SecureKeyValueStore.remove("somekey");86});87gTests.push(function test_remove_nonexistent() {88 onKeyChangedObserved(function(info) {89 do_check_eq(info.key, "nonexistent");90 do_check_eq(info.value, null);91 run_next_test();92 });93 SecureKeyValueStore.remove("nonexistent");94});95gTests.push(function test_removeAll() {96 onStoreCleared(function() {97 SecureKeyValueStore.getAll(function(data) {98 do_check_eq(data, null);99 // Removing all keys again won't do any harm.100 SecureKeyValueStore.removeAll();101 run_next_test();102 });103 });104 SecureKeyValueStore.removeAll();105});106gTests.push(function test_removeAllLogins() {107 // Add some data to the store first.108 onKeyChangedObserved(function(info) {109 // Wipe password storage.110 loginManager.removeAllLogins();111 // Ensure stuff is really gone.112 SecureKeyValueStore.getAll(function(data) {113 do_check_eq(data, null);114 run_next_test();115 });116 });117 SecureKeyValueStore.set("somekey", testdata.somekey);118});119function run_test() {120 run_next_test();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1test(function() {2 assert_true(true);3}, "Test 1");4test(function() {5 assert_true(true);6}, "Test 2");7test(function() {8 assert_true(true);9}, "Test 3");10test(function() {11 assert_true(true);12}, "Test 4");13test(function() {14 assert_true(true);15}, "Test 5");16test(function() {17 assert_true(true);18}, "Test 6");19test(function() {20 assert_true(true);21}, "Test 7");22test(function() {23 assert_true(true);24}, "Test 8");25test(function() {26 assert_true(true);27}, "Test 9");28test(function() {29 assert_true(true);30}, "Test 10");31test(function() {32 assert_true(true);33}, "Test 11");34test(function() {35 assert_true(true);36}, "Test 12");37test(function() {38 assert_true(true);39}, "Test 13");40test(function() {41 assert_true(true);42}, "Test 14");43test(function() {44 assert_true(true);45}, "Test 15");46test(function() {47 assert_true(true);48}, "Test 16");49test(function() {50 assert_true(true);51}, "Test 17");52test(function() {53 assert_true(true);54}, "Test 18");55test(function() {56 assert_true(true);57}, "Test 19");58test(function() {59 assert_true(true);60}, "Test 20");61test(function() {62 assert_true(true);63}, "Test 21");64test(function() {65 assert_true(true);66}, "Test 22");67test(function() {68 assert_true(true);69}, "Test 23");70test(function() {71 assert_true(true);72}, "Test 24");73test(function() {74 assert_true(true);75}, "Test 25");76test(function() {77 assert_true(true);78}, "Test 26");79test(function() {80 assert_true(true);81}, "Test 27");82test(function() {83 assert_true(true);84}, "Test 28");85test(function() {86 assert_true(true);87}, "Test 29");88test(function() {89 assert_true(true);90}, "Test 30");91test(function() {92 assert_true(true);93}, "Test 31");94test(function() {95 assert_true(true);96}, "Test 32");97test(function() {98 assert_true(true);99}, "Test 33");100test(function

Full Screen

Using AI Code Generation

copy

Full Screen

1function run_test() {2 do_test_pending();3 run_next_test();4}5add_test(function test_1() {6 do_test_pending();7 run_next_test();8});9add_test(function test_2() {10 do_test_pending();11 run_next_test();12});13add_test(function test_3() {14 do_test_pending();15 run_next_test();16});17add_test(function test_4() {18 do_test_pending();19 run_next_test();20});21add_test(function test_5() {22 do_test_pending();23 run_next_test();24});25add_test(function test_6() {26 do_test_pending();27 run_next_test();28});29add_test(function test_7() {30 do_test_pending();31 run_next_test();32});33add_test(function test_8() {34 do_test_pending();35 run_next_test();36});37add_test(function test_9() {38 do_test_pending();39 run_next_test();40});41add_test(function test_10() {42 do_test_pending();43 run_next_test();44});45add_test(function test_11() {46 do_test_pending();47 run_next_test();48});49add_test(function test_12() {50 do_test_pending();51 run_next_test();52});53add_test(function test_13() {54 do_test_pending();55 run_next_test();56});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var webPageTest = new wpt('www.webpagetest.org');3var fs = require('fs');4var path = require('path');5exports['test run_next_test'] = function(assert, done) {6 webPageTest.runTest(url, function(err, data) {7 assert.ok(!err, 'Error: ' + err);8 assert.ok(data, 'No data returned!');9 console.log('Test ID: ' + data.data.testId);10 console.log('Poll Results: ' + data.data.jsonUrl);11 console.log('Test Status: ' + data.data.statusText);12 console.log('Test Summary: ' + data.data.summary);13 console.log('Test Details: ' + data.data.detail);14 console.log('Test Help: ' + data.data.help);15 console.log('Test Error: ' + data.data.error);16 assert.ok(data.data.testId, 'No test ID returned!');17 assert.ok(data.data.jsonUrl, 'No JSON results URL returned!');18 assert.ok(data.data.statusText, 'No test status text returned!');19 assert.ok(data.data.summary, 'No test summary returned!');20 assert.ok(data.data.detail, 'No test details returned!');21 assert.ok(data.data.help, 'No test help returned!');22 assert.ok(data.data.error, 'No test error returned!');23 done();24 });25};26require('sdk/test').run(exports);

Full Screen

Using AI Code Generation

copy

Full Screen

1];2function test1() {3 console.log('test1');4 run_next_test();5}6function test2() {7 console.log('test2');8 run_next_test();9}10function test3() {11 console.log('test3');12 run_next_test();13}14function run_next_test() {15 var test = tests.shift();16 if (test) {17 test();18 }19}20run_next_test();21];22function test1() {23 console.log('test1');24 run_next_test();25}26function test2() {27 console.log('test2');28 run_next_test();29}30function test3() {31 console.log('test3');32 run_next_test();33}34function run_next_test() {35 var test = tests.shift();36 if (test) {37 test();38 }39}40run_next_test();41];42function test1() {43 console.log('test1');44 run_next_test();45}46function test2() {47 console.log('test2');48 run_next_test();49}50function test3() {51 console.log('test3');52 run_next_test();53}54function run_next_test() {55 var test = tests.shift();56 if (test) {57 test();58 }59}60run_next_test();61];62function test1() {63 console.log('test1');64 run_next_test();65}66function test2() {67 console.log('test2');68 run_next_test();69}70function test3() {71 console.log('test3');72 run_next_test();73}74function run_next_test() {75 var test = tests.shift();76 if (

Full Screen

Using AI Code Generation

copy

Full Screen

1test(function() {2 assert_true(true, "This is true.");3}, "Test 1");4async_test(function(t) {5 setTimeout(t.step_func(function() {6 assert_true(true, "This is true.");7 t.done();8 }), 100);9}, "Test 2");10promise_test(function() {11 return new Promise(function(resolve, reject) {12 setTimeout(function() {13 assert_true(true, "This is true.");14 resolve();15 }, 100);16 });17}, "Test 3");18promise_rejects(new TypeError(), new Promise(function(resolve, reject) {19 setTimeout(function() {20 assert_true(true, "This is true.");21 reject(new TypeError());22 }, 100);23}), "Test 4");24promise_rejects_dom(new TypeError(), new Promise(function(resolve, reject) {25 setTimeout(function() {26 assert_true(true, "This is true.");27 reject(new TypeError());28 }, 100);29}), "Test 5");30promise_rejects_exactly(new TypeError(), new Promise(function(resolve, reject) {31 setTimeout(function() {32 assert_true(true, "This is true.");33 reject(new TypeError());34 }, 100);35}), "Test 6");

Full Screen

Using AI Code Generation

copy

Full Screen

1function runTest() {2 run_next_test();3}4add_test(function() {5 ok(true, "test1");6 finish();7});8add_test(function() {9 ok(true, "test2");10 finish();11});12add_test(function() {13 ok(true, "test3");14 finish();15});16add_test(function() {17 ok(true, "test4");18 finish();19});20add_test(function() {21 ok(true, "test5");22 finish();23});24add_test(function() {25 ok(true, "test6");26 finish();27});28add_test(function() {29 ok(true, "test7");30 finish();31});32add_test(function() {33 ok(true, "test8");34 finish();35});36add_test(function() {37 ok(true, "test9");38 finish();39});40add_test(function() {41 ok(true, "test10");

Full Screen

Using AI Code Generation

copy

Full Screen

1function test_get_tabs() {2 let tabs = gBrowser.tabs;3 ok(tabs, "Get a list of all the tabs");4 run_next_test();5}6function test_tab_length() {7 let tabs = gBrowser.tabs;8 is(tabs.length, 1, "Check if there is only one tab");9 run_next_test();10}11function test_tab_title() {12 let tabs = gBrowser.tabs;13 is(tabs[0].label, "New Tab", "Check if the title of the tab is correct");14 run_next_test();15}16function test_tab_url() {17 let tabs = gBrowser.tabs;18 is(tabs[0].linkedBrowser.currentURI.spec, "about:newtab", "Check if the url of the tab is correct");19 run_next_test();20}21function test_tab_close() {22 let tabs = gBrowser.tabs;23 tabs[0].linkedBrowser.contentWindow.close();24 is(tabs.length, 0, "Check if the tab is closed");25 run_next_test();26}27function test_tab_open() {28 let tabs = gBrowser.tabs;29 let url = "about:mozilla";30 let tab = gBrowser.addTab(url);31 is(tabs.length, 1, "Check if the tab is opened");32 is(tab.linkedBrowser.currentURI.spec, url, "Check if the url of the tab is correct");33 gBrowser.removeTab(tab);34 run_next_test();35}36function test_tab_open_in_background() {37 let tabs = gBrowser.tabs;38 let url = "about:mozilla";39 let tab = gBrowser.addTab(url, {skipAnimation: true});40 is(tabs.length, 1, "Check if the tab is opened");41 is(tab.linkedBrowser.currentURI.spec, url, "Check if the url of the tab is correct");42 gBrowser.removeTab(tab);43 run_next_test();44}45function test_tab_switch() {46 let tabs = gBrowser.tabs;47 let url = "about:mozilla";48 let tab = gBrowser.addTab(url, {skipAnimation: true});49 is(tabs.length, 1, "Check if the tab is opened");50 is(tab.linkedBrowser.currentURI.spec, url, "Check if the url of the tab is correct");51 gBrowser.selectedTab = tab;

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful