Best JavaScript code snippet using appium-xcuitest-driver
listview_core.js
Source:listview_core.js  
...6  var home = $.mobile.path.parseUrl( location.href ).pathname;7	$.mobile.defaultTransition = "none";8	module( "Basic Linked list", {9		setup: function(){10			$.testHelper.openPage( "#basic-linked-test" );11		}12	});13	asyncTest( "The page should enhanced correctly", function(){14		setTimeout(function() {15			ok($('#basic-linked-test .ui-li').length, ".ui-li classes added to li elements");16			start();17		}, 800);18	});19	asyncTest( "Slides to the listview page when the li a is clicked", function() {20		$.testHelper.pageSequence([21			function(){22				$.testHelper.openPage("#basic-linked-test");23			},24			function(){25				$('#basic-linked-test li a').first().click();26			},27			function(){28				ok($('#basic-link-results').hasClass('ui-page-active'));29				start();30			}31		]);32	});33	asyncTest( "Slides back to main page when back button is clicked", function() {34		$.testHelper.pageSequence([35			function(){36				$.testHelper.openPage("#basic-link-results");37			},38			function(){39				window.history.back();40			},41			function(){42				ok($('#basic-linked-test').hasClass('ui-page-active'));43				start();44			}45		]);46	});47	asyncTest( "Presence of ui-li-has- classes", function(){48		$.testHelper.pageSequence( [49			function() {50				$.testHelper.openPage( "#ui-li-has-test" );51			},52			function() {53				var page = $( ".ui-page-active" ),54					items = page.find( "li" );55				ok(  items.eq( 0 ).hasClass( "ui-li-has-count"), "First LI should have ui-li-has-count class" );56				ok(  items.eq( 0 ).hasClass( "ui-li-has-arrow"), "First LI should have ui-li-has-arrow class" );57				ok( !items.eq( 1 ).hasClass( "ui-li-has-count"), "Second LI should NOT have ui-li-has-count class" );58				ok(  items.eq( 1 ).hasClass( "ui-li-has-arrow"), "Second LI should have ui-li-has-arrow class" );59				ok( !items.eq( 2 ).hasClass( "ui-li-has-count"), "Third LI should NOT have ui-li-has-count class" );60				ok( !items.eq( 2 ).hasClass( "ui-li-has-arrow"), "Third LI should NOT have ui-li-has-arrow class" );61				ok(  items.eq( 3 ).hasClass( "ui-li-has-count"), "Fourth LI should have ui-li-has-count class" );62				ok( !items.eq( 3 ).hasClass( "ui-li-has-arrow"), "Fourth LI should NOT have ui-li-has-arrow class" );63				ok( !items.eq( 4 ).hasClass( "ui-li-has-count"), "Fifth LI should NOT have ui-li-has-count class" );64				ok( !items.eq( 4 ).hasClass( "ui-li-has-arrow"), "Fifth LI should NOT have ui-li-has-arrow class" );65				start();66			}67		]);68	});69	module('Nested List Test');70	asyncTest( "Changes page to nested list test and enhances", function() {71		$.testHelper.pageSequence([72			function(){73				$.testHelper.openPage("#nested-list-test");74			},75			function(){76				ok($('#nested-list-test').hasClass('ui-page-active'), "makes nested list test page active");77				ok($(':jqmData(url="nested-list-test&ui-page=0-0")').length == 1, "Adds first UL to the page");78				ok($(':jqmData(url="nested-list-test&ui-page=0-1")').length == 1, "Adds second nested UL to the page");79				start();80			}81		]);82	});83	asyncTest( "change to nested page when the li a is clicked", function() {84		$.testHelper.pageSequence([85			function(){86				$.testHelper.openPage("#nested-list-test");87			},88			function(){89				$('.ui-page-active li:eq(1) a:eq(0)').click();90			},91			function(){92				var $new_page = $(':jqmData(url="nested-list-test&ui-page=0-0")');93				ok($new_page.hasClass('ui-page-active'), 'Makes the nested page the active page.');94				ok($('.ui-listview', $new_page).find(":contains('Rhumba of rattlesnakes')").length == 1, "The current page should have the proper text in the list.");95				ok($('.ui-listview', $new_page).find(":contains('Shoal of Bass')").length == 1, "The current page should have the proper text in the list.");96				start();97			}98		]);99	});100	asyncTest( "should go back to top level when the back button is clicked", function() {101		$.testHelper.pageSequence([102			function(){103				$.testHelper.openPage("#nested-list-test&ui-page=0-0");104			},105			function(){106				window.history.back();107			},108			function(){109				ok($('#nested-list-test').hasClass('ui-page-active'), 'Transitions back to the parent nested page');110				start();111			}112		]);113	});114	test( "nested list title should use first text node, regardless of line breaks", function(){115		ok($('#nested-list-test .linebreaknode').text() === "More animals", 'Text should be "More animals"');116	});117	asyncTest( "Multiple nested lists on a page with same labels", function() {118		$.testHelper.pageSequence([119			function(){120				// https://github.com/jquery/jquery-mobile/issues/1617121				$.testHelper.openPage("#nested-lists-test");122			},123			function(){124				// Click on the link of the third li element125				$('.ui-page-active li:eq(2) a:eq(0)').click();126			},127			function(){128				equal($('.ui-page-active .ui-content .ui-listview li').text(), "Item A-3-0Item A-3-1Item A-3-2", 'Text should be "Item A-3-0Item A-3-1Item A-3-2"');129				start();130			}131		]);132	});133	module('Ordered Lists');134	asyncTest( "changes to the numbered list page and enhances it", function() {135		$.testHelper.pageSequence([136			function(){137				$.testHelper.openPage("#numbered-list-test");138			},139			function(){140				var $new_page = $('#numbered-list-test');141				ok($new_page.hasClass('ui-page-active'), "Makes the new page active when the hash is changed.");142				ok($('.ui-link-inherit', $new_page).first().text() == "Number 1", "The text of the first LI should be Number 1");143				start();144			}145		]);146	});147	asyncTest( "changes to number 1 page when the li a is clicked", function() {148		$.testHelper.pageSequence([149			function(){150				$('#numbered-list-test li a').first().click();151			},152			function(){153				ok($('#numbered-list-results').hasClass('ui-page-active'), "The new numbered page was transitioned correctly.");154				start();155			}156		]);157	});158	asyncTest( "takes us back to the numbered list when the back button is clicked", function() {159		$.testHelper.pageSequence([160			function(){161				$.testHelper.openPage('#numbered-list-test');162			},163			function(){164				$.testHelper.openPage('#numbered-list-results');165			},166			function(){167				window.history.back();168			},169			function(){170				ok($('#numbered-list-test').hasClass('ui-page-active'));171				start();172			}173		]);174	});175	module('Read only list');176	asyncTest( "changes to the read only page when hash is changed", function() {177		$.testHelper.pageSequence([178			function(){179				$.testHelper.openPage("#read-only-list-test");180			},181			function(){182				var $new_page = $('#read-only-list-test');183				ok($new_page.hasClass('ui-page-active'), "makes the read only page the active page");184				ok($('li', $new_page).first().text() === "Read", "The first LI has the proper text.");185				start();186			}187		]);188	});189	module('Split view list');190	asyncTest( "changes the page to the split view list and enhances it correctly.", function() {191		$.testHelper.pageSequence([192			function(){193				$.testHelper.openPage("#split-list-test");194			},195			function(){196				var $new_page = $('#split-list-test');197				ok($('.ui-li-link-alt', $new_page).length == 3);198				ok($('.ui-link-inherit', $new_page).length == 3);199				start();200			}201		]);202	});203	asyncTest( "change the page to the split view page 1 when the first link is clicked", function() {204		$.testHelper.pageSequence([205			function(){206				$.testHelper.openPage("#split-list-test");207			},208			function(){209				$('.ui-page-active .ui-li a:eq(0)').click();210			},211			function(){212				ok($('#split-list-link1').hasClass('ui-page-active'));213				start();214			}215		]);216	});217	asyncTest( "Slide back to the parent list view when the back button is clicked", function() {218		$.testHelper.pageSequence([219			function(){220				$.testHelper.openPage("#split-list-test");221			},222			function(){223				$('.ui-page-active .ui-listview a:eq(0)').click();224			},225			function(){226				history.back();227			},228			function(){229				ok($('#split-list-test').hasClass('ui-page-active'));230				start();231			}232		]);233	});234	asyncTest( "Clicking on the icon (the second link) should take the user to other a href of this LI", function() {235		$.testHelper.pageSequence([236			function(){237				$.testHelper.openPage("#split-list-test");238			},239			function(){240				$('.ui-page-active .ui-li-link-alt:eq(0)').click();241			},242			function(){243				ok($('#split-list-link2').hasClass('ui-page-active'));244				start();245			}246		]);247	});248	module( "List Dividers" );249	asyncTest( "Makes the list divider page the active page and enhances it correctly.", function() {250		$.testHelper.pageSequence([251			function(){252				$.testHelper.openPage("#list-divider-test");253			},254			function(){255				var $new_page = $('#list-divider-test');256				ok($new_page.find('.ui-li-divider').length == 2);257				ok($new_page.hasClass('ui-page-active'));258				start();259			}260		]);261	});262	module( "Search Filter");263	var searchFilterId = "#search-filter-test";264	asyncTest( "Filter downs results when the user enters information", function() {265		var $searchPage = $(searchFilterId);266		$.testHelper.pageSequence([267			function() {268				$.testHelper.openPage(searchFilterId);269			},270			function() {271				$searchPage.find('input').val('at');272				$searchPage.find('input').trigger('change');273				same($searchPage.find('li.ui-screen-hidden').length, 2);274				start();275			}276		]);277	});278	asyncTest( "Redisplay results when user removes values", function() {279		var $searchPage = $(searchFilterId);280		$.testHelper.pageSequence([281			function() {282				$.testHelper.openPage(searchFilterId);283			},284			function() {285				$searchPage.find('input').val('a');286				$searchPage.find('input').trigger('change');287				same($searchPage.find("li[style^='display: none;']").length, 0);288				start();289			}290		]);291	});292    asyncTest( "Filter works fine with \\W- or regexp-special-characters", function() {293        var $searchPage = $(searchFilterId);294        $.testHelper.pageSequence([295            function() {296                $.testHelper.openPage(searchFilterId);297            },298            function() {299                $searchPage.find('input').val('*');300                $searchPage.find('input').trigger('change');301                same($searchPage.find('li.ui-screen-hidden').length, 4);302                start();303            }304        ]);305    });306	test( "Refresh applies thumb styling", function(){307		var ul = $('.ui-page-active ul');308		ul.append("<li id='fiz'><img/></li>");309		ok(!ul.find("#fiz img").hasClass("ui-li-thumb"));310		ul.listview('refresh');311		ok(ul.find("#fiz img").hasClass("ui-li-thumb"));312	});313	asyncTest( "Filter downs results and dividers when the user enters information", function() {314		var	$searchPage = $("#search-filter-with-dividers-test");315		$.testHelper.pageSequence([316			function() {317				$.testHelper.openPage("#search-filter-with-dividers-test");318			},319			// wait for the page to become active/enhanced320			function(){321				$searchPage.find('input').val('at');322				$searchPage.find('input').trigger('change');323				setTimeout(function() {324					//there should be four hidden list entries325					same($searchPage.find('li.ui-screen-hidden').length, 4);326					//there should be two list entries that are list dividers and hidden327					same($searchPage.find('li.ui-screen-hidden:jqmData(role=list-divider)').length, 2);328					//there should be two list entries that are not list dividers and hidden329					same($searchPage.find('li.ui-screen-hidden:not(:jqmData(role=list-divider))').length, 2);330					start();331				}, 1000);332			}333		]);334	});335	asyncTest( "Redisplay results when user removes values", function() {336		$.testHelper.pageSequence([337			function() {338				$.testHelper.openPage("#search-filter-with-dividers-test");339			},340			function() {341				$('.ui-page-active input').val('a');342				$('.ui-page-active input').trigger('change');343				setTimeout(function() {344					same($('.ui-page-active input').val(), 'a');345					same($('.ui-page-active li[style^="display: none;"]').length, 0);346					start();347				}, 1000);348			}349		]);350	});351	asyncTest( "Dividers are hidden when preceding hidden rows and shown when preceding shown rows", function () {352		$.testHelper.pageSequence([353			function() {354				$.testHelper.openPage("#search-filter-with-dividers-test");355			},356			function() {357				var $page = $('.ui-page-active');358				$page.find('input').val('at');359				$page.find('input').trigger('change');360				setTimeout(function() {361					same($page.find('li:jqmData(role=list-divider):hidden').length, 2);362					same($page.find('li:jqmData(role=list-divider):hidden + li:not(:jqmData(role=list-divider)):hidden').length, 2);363					same($page.find('li:jqmData(role=list-divider):not(:hidden) + li:not(:jqmData(role=list-divider)):not([:hidden)').length, 2);364					start();365				}, 1000);366			}367		]);368	});369	asyncTest( "Inset List View should refresh corner classes after filtering", 4 * 2, function () {370		var checkClasses = function() {371			var $page = $( ".ui-page-active" ),372				$li = $page.find( "li:visible" );373			ok($li.first().hasClass( "ui-corner-top" ), $li.length+" li elements: First visible element should have class ui-corner-top");374			ok($li.last().hasClass( "ui-corner-bottom" ), $li.length+" li elements: Last visible element should have class ui-corner-bottom");375		};376		$.testHelper.pageSequence([377			function() {378				$.testHelper.openPage("#search-filter-inset-test");379			},380			function() {381				var $page = $('.ui-page-active');382				$.testHelper.sequence([383					function() {384						checkClasses();385						$page.find('input').val('man');386						$page.find('input').trigger('change');387					},388					function() {389						checkClasses();390						$page.find('input').val('at');391						$page.find('input').trigger('change');392					},393					function() {394						checkClasses();395						$page.find('input').val('catwoman');396						$page.find('input').trigger('change');397					},398					function() {399						checkClasses();400						start();401					}402				], 50);403			}404		]);405	});406	module( "Programmatically generated list items", {407		setup: function(){408			var item,409				data = [410					{411						id: 1,412						label: "Item 1"413					},414					{415						id: 2,416						label: "Item 2"417					},418					{419						id: 3,420						label: "Item 3"421					},422					{423						id: 4,424						label: "Item 4"425					}426				];427			$( "#programmatically-generated-list-items" ).html("");428			for ( var i = 0, len = data.length; i < len; i++ ) {429				item = $( '<li id="myItem' + data[i].id + '">' );430				label = $( "<strong>" + data[i].label + "</strong>").appendTo( item );431				$( "#programmatically-generated-list-items" ).append( item );432			}433		}434	});435	asyncTest( "Corner styling on programmatically created list items", function() {436		// https://github.com/jquery/jquery-mobile/issues/1470437		$.testHelper.pageSequence([438			function() {439				$.testHelper.openPage( "#programmatically-generated-list" );440			},441			function() {442				ok(!$( "#programmatically-generated-list-items li:first-child" ).hasClass( "ui-corner-bottom" ), "First list item should not have class ui-corner-bottom" );443				start();444			}445		]);446	});447	module("Programmatic list items manipulation");448	asyncTest("Removing list items", 4, function() {449		$.testHelper.pageSequence([450			function() {451				$.testHelper.openPage("#removing-items-from-list-test");452			},453			function() {454				var ul = $('#removing-items-from-list-test ul');455				ul.find("li").first().remove();456				equal(ul.find("li").length, 3, "There should be only 3 list items left");457				ul.listview('refresh');458				ok(ul.find("li").first().hasClass("ui-corner-top"), "First list item should have class ui-corner-top");459				ul.find("li").last().remove();460				equal(ul.find("li").length, 2, "There should be only 2 list items left");461				ul.listview('refresh');462				ok(ul.find("li").last().hasClass("ui-corner-bottom"), "Last list item should have class ui-corner-bottom");463				start();464			}465		]);466	});467	module("Rounded corners");468	asyncTest("Top and bottom corners rounded in inset list", 14, function() {469		$.testHelper.pageSequence([470			function() {471				$.testHelper.openPage("#corner-rounded-test");472			},473			function() {474				var ul = $('#corner-rounded-test ul');475				for( var t = 0; t<3; t++){476					ul.append("<li>Item " + t + "</li>");477					ul.listview('refresh');478					equals(ul.find(".ui-corner-top").length, 1, "There should be only one element with class ui-corner-top");479					equals(ul.find("li:visible").first()[0], ul.find(".ui-corner-top")[0], "First list item should have class ui-corner-top in list with " + ul.find("li").length + " item(s)");480					equals(ul.find(".ui-corner-bottom").length, 1, "There should be only one element with class ui-corner-bottom");481					equals(ul.find("li:visible").last()[0], ul.find(".ui-corner-bottom")[0], "Last list item should have class ui-corner-bottom in list with " + ul.find("li").length + " item(s)");482				}483				ul.find( "li" ).first().hide();484				ul.listview( "refresh" );485				equals(ul.find("li:visible").first()[0], ul.find(".ui-corner-top")[0], "First visible list item should have class ui-corner-top");486				ul.find( "li" ).last().hide();487				ul.listview( "refresh" );488				equals(ul.find("li:visible").last()[0], ul.find(".ui-corner-bottom")[0], "Last visible list item should have class ui-corner-bottom");489				start();490			}491		]);492	});493	test( "Listview will create when inside a container that receives a 'create' event", function(){494		ok( !$("#enhancetest").appendTo(".ui-page-active").find(".ui-listview").length, "did not have enhancements applied" );495		ok( $("#enhancetest").trigger("create").find(".ui-listview").length, "enhancements applied" );496	});497	module( "Cached Linked List" );498	var findNestedPages = function(selector){499		return $( selector + " #topmost" ).listview( 'childPages' );500	};501	asyncTest( "nested pages are removed from the dom by default", function(){502		$.testHelper.pageSequence([503			function(){504				//reset for relative url refs505				$.testHelper.openPage( "#" + home );506			},507			function(){508				$.testHelper.openPage( "#cache-tests/uncached-nested.html" );509			},510			function(){511				ok( findNestedPages( "#uncached-nested-list" ).length > 0, "verify that there are nested pages" );512				$.testHelper.openPage( "#" + home );513			},514			function() {515				$.testHelper.openPage( "#cache-tests/clear.html" );516			},517			function(){518				same( findNestedPages( "#uncached-nested-list" ).length, 0 );519				start();520			}521		]);522	});523	asyncTest( "nested pages preserved when parent page is cached", function(){524		$.testHelper.pageSequence([525			function(){526				//reset for relative url refs527				$.testHelper.openPage( "#" + home );528			},529			function(){530				$.testHelper.openPage( "#cache-tests/cached-nested.html" );531			},532			function(){533				ok( findNestedPages( "#cached-nested-list" ).length > 0, "verify that there are nested pages" );534				$.testHelper.openPage( "#" + home );535			},536			function() {537				$.testHelper.openPage( "#cache-tests/clear.html" );538			},539			function(){540				ok( findNestedPages( "#cached-nested-list" ).length > 0, "nested pages remain" );541				start();542			}543		]);544	});545	asyncTest( "parent page is not removed when visiting a sub page", function(){546		$.testHelper.pageSequence([547			function(){548				//reset for relative url refs549				$.testHelper.openPage( "#" + home );550			},551			function(){552				$.testHelper.openPage( "#cache-tests/cached-nested.html" );553			},554			function(){555				same( $("#cached-nested-list").length, 1 );556				$.testHelper.openPage( "#" + home );557			},558			function() {559				$.testHelper.openPage( "#cache-tests/clear.html" );560			},561			function(){562				same( $("#cached-nested-list").length, 1 );563				start();564			}565		]);566	});567	asyncTest( "filterCallback can be altered after widget creation", function(){568		var listPage = $( "#search-filter-test" );569		expect( listPage.find("li").length );570		$.testHelper.pageSequence( [571			function(){572				//reset for relative url refs573				$.testHelper.openPage( "#" + home );574			},575			function() {576				$.testHelper.openPage( "#search-filter-test" );577			},578			function() {579				// set the listview instance callback580				listPage.find( "ul" ).listview( "option", "filterCallback", function() {581					ok(true, "custom callback invoked");582				});583				// trigger a change in the search filter584				listPage.find( "input" ).val( "foo" ).trigger( "change" );585				//NOTE beware a poossible issue with timing here586				start();587			}588		]);589	});590	asyncTest( "nested pages hash key is always in the hash (replaceState)", function(){591		$.testHelper.pageSequence([592			function(){593				//reset for relative url refs594				$.testHelper.openPage( "#" + home );595			},596			function(){597				// https://github.com/jquery/jquery-mobile/issues/1617598				$.testHelper.openPage("#nested-lists-test");599			},600			function(){601				// Click on the link of the third li element602				$('.ui-page-active li:eq(2) a:eq(0)').click();603			},604			function(){605				ok( location.hash.search($.mobile.subPageUrlKey) >= 0 );606				start();607			}608		]);609	});610	asyncTest( "embedded listview page with nested pages is not removed from the dom", function() {611		$.testHelper.pageSequence([612			function() {613				// open the nested list page614				same( $("div#nested-list-test").length, 1 );615				$( "a#nested-list-test-anchor" ).click();616			},617			function() {618				// go back to the origin page619				window.history.back();620			},621			function() {622				// make sure the page is still in place623				same( $("div#nested-list-test").length, 1 );624				start();625			}626		]);627	});628	asyncTest( "list inherits theme from parent", function() {629		$.testHelper.pageSequence([630			function() {631				$.testHelper.openPage("#list-theme-inherit");632			},633			function() {634				var theme = $.mobile.activePage.jqmData('theme');635				ok( $.mobile.activePage.find("ul > li").hasClass("ui-body-b"), "theme matches the parent");636				window.history.back();637			},638			start639		]);640	});...test_browserGlue_urlbar_defaultbehavior_migration.js
Source:test_browserGlue_urlbar_defaultbehavior_migration.js  
1/* This Source Code Form is subject to the terms of the Mozilla Public2 * License, v. 2.0. If a copy of the MPL was not distributed with this3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */4const UI_VERSION = 26;5const TOPIC_BROWSERGLUE_TEST = "browser-glue-test";6const TOPICDATA_BROWSERGLUE_TEST = "force-ui-migration";7const DEFAULT_BEHAVIOR_PREF = "browser.urlbar.default.behavior";8const AUTOCOMPLETE_PREF = "browser.urlbar.autocomplete.enabled";9var gBrowserGlue = Cc["@mozilla.org/browser/browserglue;1"]10                     .getService(Ci.nsIObserver);11var gGetBoolPref = Services.prefs.getBoolPref;12function run_test() {13  run_next_test();14}15do_register_cleanup(cleanup);16function cleanup() {17  let prefix = "browser.urlbar.suggest.";18  for (let type of ["history", "bookmark", "openpage", "history.onlyTyped"]) {19    Services.prefs.clearUserPref(prefix + type);20  }21  Services.prefs.clearUserPref("browser.migration.version");22  Services.prefs.clearUserPref(AUTOCOMPLETE_PREF);23}24function setupBehaviorAndMigrate(aDefaultBehavior, aAutocompleteEnabled = true) {25  cleanup();26  // Migrate browser.urlbar.default.behavior preference.27  Services.prefs.setIntPref("browser.migration.version", UI_VERSION - 1);28  Services.prefs.setIntPref(DEFAULT_BEHAVIOR_PREF, aDefaultBehavior);29  Services.prefs.setBoolPref(AUTOCOMPLETE_PREF, aAutocompleteEnabled);30  // Simulate a migration.31  gBrowserGlue.observe(null, TOPIC_BROWSERGLUE_TEST, TOPICDATA_BROWSERGLUE_TEST);32}33add_task(async function() {34  do_print("Migrate default.behavior = 0");35  setupBehaviorAndMigrate(0);36  Assert.ok(gGetBoolPref("browser.urlbar.suggest.history"),37    "History preference should be true.");38  Assert.ok(gGetBoolPref("browser.urlbar.suggest.bookmark"),39    "Bookmark preference should be true.");40  Assert.ok(gGetBoolPref("browser.urlbar.suggest.openpage"),41    "Openpage preference should be true.");42  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"), false,43    "Typed preference should be false.");44});45add_task(async function() {46  do_print("Migrate default.behavior = 1");47  setupBehaviorAndMigrate(1);48  Assert.ok(gGetBoolPref("browser.urlbar.suggest.history"),49    "History preference should be true.");50  Assert.equal(gGetBoolPref("browser.urlbar.suggest.bookmark"), false,51    "Bookmark preference should be false.");52  Assert.equal(gGetBoolPref("browser.urlbar.suggest.openpage"), false,53    "Openpage preference should be false");54  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"), false,55    "Typed preference should be false");56});57add_task(async function() {58  do_print("Migrate default.behavior = 2");59  setupBehaviorAndMigrate(2);60  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history"), false,61    "History preference should be false.");62  Assert.ok(gGetBoolPref("browser.urlbar.suggest.bookmark"),63    "Bookmark preference should be true.");64  Assert.equal(gGetBoolPref("browser.urlbar.suggest.openpage"), false,65    "Openpage preference should be false");66  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"), false,67    "Typed preference should be false");68});69add_task(async function() {70  do_print("Migrate default.behavior = 3");71  setupBehaviorAndMigrate(3);72  Assert.ok(gGetBoolPref("browser.urlbar.suggest.history"),73    "History preference should be true.");74  Assert.ok(gGetBoolPref("browser.urlbar.suggest.bookmark"),75    "Bookmark preference should be true.");76  Assert.equal(gGetBoolPref("browser.urlbar.suggest.openpage"), false,77    "Openpage preference should be false");78  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"), false,79    "Typed preference should be false");80});81add_task(async function() {82  do_print("Migrate default.behavior = 19");83  setupBehaviorAndMigrate(19);84  Assert.ok(gGetBoolPref("browser.urlbar.suggest.history"),85    "History preference should be true.");86  Assert.ok(gGetBoolPref("browser.urlbar.suggest.bookmark"),87    "Bookmark preference should be true.");88  Assert.equal(gGetBoolPref("browser.urlbar.suggest.openpage"), false,89    "Openpage preference should be false");90  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"), false,91    "Typed preference should be false");92});93add_task(async function() {94  do_print("Migrate default.behavior = 33");95  setupBehaviorAndMigrate(33);96  Assert.ok(gGetBoolPref("browser.urlbar.suggest.history"),97    "History preference should be true.");98  Assert.equal(gGetBoolPref("browser.urlbar.suggest.bookmark"), false,99    "Bookmark preference should be false.");100  Assert.equal(gGetBoolPref("browser.urlbar.suggest.openpage"), false,101    "Openpage preference should be false");102  Assert.ok(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"),103    "Typed preference should be true");104});105add_task(async function() {106  do_print("Migrate default.behavior = 129");107  setupBehaviorAndMigrate(129);108  Assert.ok(gGetBoolPref("browser.urlbar.suggest.history"),109    "History preference should be true.");110  Assert.equal(gGetBoolPref("browser.urlbar.suggest.bookmark"), false,111    "Bookmark preference should be false.");112  Assert.ok(gGetBoolPref("browser.urlbar.suggest.openpage"),113    "Openpage preference should be true");114  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"), false,115    "Typed preference should be false");116});117add_task(async function() {118  do_print("Migrate default.behavior = 0, autocomplete.enabled = false");119  setupBehaviorAndMigrate(0, false);120  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history"), false,121    "History preference should be false.");122  Assert.equal(gGetBoolPref("browser.urlbar.suggest.bookmark"), false,123    "Bookmark preference should be false.");124  Assert.equal(gGetBoolPref("browser.urlbar.suggest.openpage"), false,125    "Openpage preference should be false");126  Assert.equal(gGetBoolPref("browser.urlbar.suggest.history.onlyTyped"), false,127    "Typed preference should be false");...router.js
Source:router.js  
2    "use strict";3    function Router(navigationController) {4        _.each(this.lightboxes, function(name, path) {5            this.routes[path + "(?:query)"] = function() {6                this.openPage("MainOverview", undefined, path);7            };8        }, this);9        this.basePath = navigationController.application.basePath;10        this.controller = navigationController;11        var root = "/";12        if (navigationController.application.baseUrl.indexOf("/build") > -1) {13            root = "/build";14        }15        var self = this;16        setZeroTimeout(function() {17            window.addEventListener("popstate", _.bind(self._onStatePopped, self));18            var routeFound = self._activateRoute();19            if (!routeFound) {20                self.controller.application.notificationBus.signal("router:noRoute");21            }22        }, 0);23    }24    _.extend(Router.prototype, {25        getCurrentPagePath: function() {26            var currentPath = "/" + location.pathname.substr(this.basePath.length);27            _.each(this.lightboxes, function(name, path) {28                if (currentPath.slice(-path.length - 1) === "/" + path) {29                    currentPath = currentPath.substr(0, currentPath.length - path.length - 1);30                }31            });32            return currentPath.substr(1);33        },34        openPage: function(type, id, path) {35            this.controller.openPage(type, id, path);36        },37        navigate: function(path) {38            history.pushState({}, "", this.basePath + path);39            this._activateRoute();40        },41        routes: {42            "": function(path) {43                this.openPage("CampaignsOverview", undefined, path);44            },45            "campaigns(/:path)": function(path) {46                this.openPage("CampaignsOverview", undefined, path);47            },48            "campaign/new": function(path) {49                this.openPage("NewCampaign", undefined, path);50            },51            "campaign/:id/edit": function(id, path) {52                this.openPage("EditCampaign", id, path);53            },54            "headquarters(/:path)": function(path) {55                this.openPage("Headquarters", undefined, path);56            },57            "help(/:path)": function(path) {58                this.openPage("Help", undefined, path);59            },60            "missions(/:path)": function(path) {61                this.openPage("MissionsOverview", undefined, path);62            },63            "mission/:id(/:path)": function(id, path) {64                this.openPage("Mission", id, path);65            },66            "settings(/:path)": function(path) {67                this.openPage("Settings", undefined, path);68            }69        },70        lightboxes: {},71        _activateRoute: function() {72            function routeToRegExp(route) {73                var optionalParam = /\((.*?)\)/g;74                var namedParam    = /(\(\?)?:\w+/g;75                var splatParam    = /\*\w+/g;76                var escapeRegExp  = /[\-{}\[\]+?.,\\\^$|#\s]/g;77                route = route78                    .replace(escapeRegExp, "\\$&")79                    .replace(optionalParam, "(?:$1)?")80                    .replace(namedParam, function(match, optional) {81                        return optional ? match : '([^\/]+)';...index.js
Source:index.js  
...16import { PostEventSource } from "../common/Utils";17import { openPage } from "./actions";18const routes = {19  "/": (_, { page, sort, order }) =>20    openPage({ id: "executions/started", page, sort, order }),21  "/executions/started": (_, { page, sort, order }) =>22    openPage({ id: "executions/started", page, sort, order }),23  "/executions/stuck": (_, { page, sort, order }) =>24    openPage({ id: "executions/stuck", page, sort, order }),25  "/executions/finished": (_, { page, sort, order }) =>26    openPage({ id: "executions/finished", page, sort, order }),27  "/executions/:id": ({ id }) =>28    openPage({ id: "executions/detail", execution: id }),29  "/workflow/*": ({ _ }, { showDetail, refPath }) =>30    openPage({31      id: "workflow",32      jobId: _,33      showDetail: showDetail === "true",34      refPath35    }),36  "/workflow": () => openPage({ id: "workflow", showDetail: false }),37  "/timeseries/calendar": () => openPage({ id: "timeseries/calendar" }),38  "/timeseries/calendar/:start_:end": ({ start, end }) =>39    openPage({ id: "timeseries/calendar/focus", start, end }),40  "/timeseries/backfills": (_, { page, sort, order }) =>41    openPage({ id: "timeseries/backfills", page, sort, order }),42  "/timeseries/backfills/create": () =>43    openPage({ id: "timeseries/backfills/create" }),44  "/timeseries/backfills/:backfillId": (45    { backfillId },46    { page, sort, order }47  ) =>48    openPage({49      id: "timeseries/backfills/detail",50      backfillId,51      page,52      sort,53      order54    }),55  "/timeseries/executions/*": ({ _ }) => {56    return openPage({57      id: "timeseries/executions",58      ...parseExecutionsRoute(_)59    });60  },61  "/jobs/:status": ({ status }, { sort, order }) =>62    openPage({ id: "jobs", status, sort, order })63};64const parseExecutionsRoute = (() => {65  const executionsRouteRegex = /([^/]+)\/([^_]+)_([^/?#]+).*/;66  return (queryString: string) => {67    const match = executionsRouteRegex.exec(queryString);68    return (69      match && {70        job: match[1],71        start: match[2],72        end: match[3]73      }74    );75  };76})();...model-management-tree-browse.spec.js
Source:model-management-tree-browse.spec.js  
...3describe('Models management tree - browsing', () => {4  let tree;5  let modelData;6  let sandbox;7  function openPage(systemLang, userLang, modelId) {8    sandbox = new ModelManagementSandbox();9    sandbox.open(userLang, systemLang, modelId);10    tree = sandbox.getModelTree();11    modelData = sandbox.getModelData();12  }13  it('should list a tree of models ready to be browsed', () => {14    openPage();15    expect(tree.getNode('Entity').isDisplayed()).to.eventually.be.true;16  });17  it('should have the search option for nodes enabled', () => {18    openPage();19    expect(tree.isSearchEnabled()).to.eventually.be.true;20  });21  it('should have the root node expanded by default', () => {22    openPage();23    expect(tree.getNode('Entity').isExpanded()).to.eventually.be.true;24  });25  it('should provide model id as a query parameter when a node is clicked', () => {26    openPage();27    tree.search('Situation');28    tree.getNode('Situation').openObject();29    expect(sandbox.isModelProvided('http://www.ontotext.com/proton/protontop#Situation')).to.eventually.be.true;30  });31  it('should directly navigate and expand to a provided model', () => {32    openPage('en', 'bg', 'http://www.ontotext.com/proton/protontop#Situation');33    expect(tree.getNode('Situation').isDisplayed()).to.eventually.be.true;34  });35  it('should be able to search nodes by name when typing in search field', () => {36    openPage();37    tree.search('Situation');38    expect(tree.getNode('Situation').isDisplayed()).to.eventually.be.true;39  });40  it('should be able to search nodes when arbitrary language is provided', () => {41    openPage('bg');42    tree.search('СиÑÑаÑиÑ');43    expect(tree.getNode('СиÑÑаÑиÑ').isDisplayed()).to.eventually.be.true;44  });45  it('should expand the root node when search query is cleared', () => {46    openPage();47    tree.search('Situation');48    expect(tree.getNode('Situation').isDisplayed()).to.eventually.be.true;49    tree.search('');50    expect(tree.getNode('Entity').isExpanded()).to.eventually.be.true;51  });52  it('should display the entire hierarchy inside the tree', () => {53    openPage();54    expandAndAssertTree(tree, {55      id: 'Entity',56      children: [{57        id: 'entity',58      }, {59        id: 'Abstract',60      }, {61        id: 'Happening',62        children: [{63          id: 'Event',64        }, {65          id: 'Situation',66        }, {67          id: 'Time Interval',68        }]69      }]70    });71  });72  it('should list the tree in the specified user language', () => {73    openPage('bg');74    expandAndAssertTree(tree, {75      id: 'ÐбекÑ',76      children: [{77        id: 'обекÑ',78      }, {79        id: 'ÐбÑÑÑакÑ',80      }, {81        // fallback EN82        id: 'Happening',83        children: [{84          id: 'СÑбиÑие',85        }, {86          id: 'СиÑÑаÑиÑ',87        }, {...test_local_suggest_prefs.js
Source:test_local_suggest_prefs.js  
1/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-2 * vim:set ts=2 sw=2 sts=2 et:3 * This Source Code Form is subject to the terms of the Mozilla Public4 * License, v. 2.0. If a copy of the MPL was not distributed with this5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */6// Test for following preferences related to local suggest.7// * browser.urlbar.suggest.bookmark8// * browser.urlbar.suggest.history9// * browser.urlbar.suggest.openpage10testEngine_setup();11add_task(async function setup() {12  Services.prefs.setBoolPref("browser.urlbar.autoFill", false);13  Services.prefs.setBoolPref("browser.urlbar.suggest.engines", false);14  const uri = Services.io.newURI("http://example.com/");15  await PlacesTestUtils.addVisits([{ uri, title: "example" }]);16  await PlacesUtils.bookmarks.insert({17    url: uri,18    parentGuid: PlacesUtils.bookmarks.toolbarGuid,19  });20  await addOpenPages(uri);21  registerCleanupFunction(async () => {22    Services.prefs.clearUserPref("browser.urlbar.autoFill");23    Services.prefs.clearUserPref("browser.urlbar.suggest.engines");24    Services.prefs.clearUserPref("browser.urlbar.suggest.bookmark");25    Services.prefs.clearUserPref("browser.urlbar.suggest.history");26    Services.prefs.clearUserPref("browser.urlbar.suggest.openpage");27    await cleanupPlaces();28  });29});30add_task(async function test_prefs() {31  const testData = [32    {33      bookmark: true,34      history: true,35      openpage: true,36    },37    {38      bookmark: false,39      history: true,40      openpage: true,41    },42    {43      bookmark: true,44      history: false,45      openpage: true,46    },47    {48      bookmark: true,49      history: true,50      openpage: false,51    },52    {53      bookmark: false,54      history: false,55      openpage: true,56    },57    {58      bookmark: false,59      history: true,60      openpage: false,61    },62    {63      bookmark: true,64      history: false,65      openpage: false,66    },67    {68      bookmark: false,69      history: false,70      openpage: false,71    },72  ];73  for (const { bookmark, history, openpage } of testData) {74    Services.prefs.setBoolPref("browser.urlbar.suggest.bookmark", bookmark);75    Services.prefs.setBoolPref("browser.urlbar.suggest.history", history);76    Services.prefs.setBoolPref("browser.urlbar.suggest.openpage", openpage);77    info(`Test bookmark:${bookmark} history:${history} openpage:${openpage}`);78    const context = createContext("e", { isPrivate: false });79    const matches = [];80    matches.push(81      makeSearchResult(context, {82        engineName: SUGGESTIONS_ENGINE_NAME,83        heuristic: true,84      })85    );86    if (openpage) {87      matches.push(88        makeTabSwitchResult(context, {89          uri: "http://example.com/",90          title: "example",91        })92      );93    } else if (bookmark) {94      matches.push(95        makeBookmarkResult(context, {96          uri: "http://example.com/",97          title: "example",98        })99      );100    } else if (history) {101      matches.push(102        makeVisitResult(context, {103          uri: "http://example.com/",104          title: "example",105        })106      );107    }108    await check_results({ context, matches });109  }...init.js
Source:init.js  
1let init = (chapterResponse) => {2    let controller = new Reader(chapterResponse);3    const $ = document.querySelector.bind(document);4    let openPage = controller.Chapter.openPage();5    $('#expand').setAttribute('href', openPage.pageImgFile);6    $('#imgFile').setAttribute('src', openPage.pageImgFile);7    $('#selectPages').innerHTML = controller.optionsTemplate;8    $('body')9        .addEventListener('keydown', (event) => {10            let key = event.keyCode;11            if (key == 37) {12                event.preventDefault();13                controller.previousPage();14                controller.selected($('#selectPages'), controller.Chapter.position);15                let openPage = controller.Chapter.openPage();16                $('#expand').setAttribute('href', openPage.pageImgFile);17                $('#imgFile').setAttribute('src', openPage.pageImgFile);18                window.scrollTo(0, 0);19            }20            if (key == 39) {21                event.preventDefault();22                23                controller.nextPage();24                controller.selected($('#selectPages'), controller.Chapter.position);25                let openPage = controller.Chapter.openPage();26                $('#expand').setAttribute('href', openPage.pageImgFile);27                $('#imgFile').setAttribute('src', openPage.pageImgFile);28                window.scrollTo(0, 0);29            }30        });31    $('#imgFile')32        .addEventListener('click', () => {33            controller.nextPage();34            controller.selected($('#selectPages'), controller.Chapter.position);35            let openPage = controller.Chapter.openPage();36            $('#expand').setAttribute('href', openPage.pageImgFile);37            $('#imgFile').setAttribute('src', openPage.pageImgFile);38            window.scrollTo(0, 0);39        });40    $('#selectPages')41        .addEventListener('change', () => {42            pageOption = $('#selectPages').value;43            controller.Chapter.position = pageOption;44            let openPage = controller.Chapter.openPage();45            $('#expand').setAttribute('href', openPage.pageImgFile);46            $('#imgFile').setAttribute('src', openPage.pageImgFile);47            window.scrollTo(0, 0);48        });49    $('#previous')50        .addEventListener('click', () => {51            controller.previousPage();52            controller.selected($('#selectPages'), controller.Chapter.position);53            let openPage = controller.Chapter.openPage();54            $('#expand').setAttribute('href', openPage.pageImgFile);55            $('#imgFile').setAttribute('src', openPage.pageImgFile);56            window.scrollTo(0, 0);57        });58    $('#next')59        .addEventListener('click', () => {60            controller.nextPage();61            controller.selected($('#selectPages'), controller.Chapter.position);62            let openPage = controller.Chapter.openPage();63            $('#expand').setAttribute('href', openPage.pageImgFile);64            $('#imgFile').setAttribute('src', openPage.pageImgFile);65            window.scrollTo(0, 0);66        });...loginPage.js
Source:loginPage.js  
1 2 function loginPageLoad(){3    let openPage = false;4    let openUserPage = "";5    let login = document.getElementById("loginButton");6    login.onclick=checkUser;7    function checkUser() {8        alert("added new book");9      checkPassword();10      openPageLibrary();11      function userAccount() {12        return [13          {14            role: "librarian",15            userName: "kaleb",16            password: "123",17          },18          {19            role: "admin",20            userName: "ezra",21            password: "124",22          },23          {24            role: "superAdmin",25            userName: "redda",26            password: "125",27          },28        ];29      }30       /**31     * check user role ,user name and user password32     */33      function checkPassword() {34        let users = userAccount();35        let user_role = document.getElementById("roleId").value;36        let user_name = document.getElementById("username").value;37        let user_password = document.getElementById("password").value;38        for (let user of users) {39          if (40            user.userName === user_name &&41            user.password === user_password &&42            user.role === user_role43          ) {44            openPage = true;45            openUserPage = user_role;46          }47        }48      }49      function openPageLibrary() {50        if (openPage && openUserPage === "librarian") {51          document.getElementById("loginstatus").className = "hidLogin";52          document.getElementById("pageLibrarian").className =53            "displayLibararianPage";54          openPage = false;55          openUserPage = "";56        } else if (openPage && openUserPage === "admin") {57          document.getElementById("loginstatus").className = "hidLogin";58          document.getElementById("pageAdmin").className = "displayAdminPage";59          openPage = false;60          openUserPage = "";61        } else if (openPage && openUserPage === "superAdmin") {62          document.getElementById("loginstatus").className = "hidLogin";63          document.getElementById("pageSuperAdmin").className =64            "displaySuperAdminPage";65          openPage = false;66          openUserPage = "";67        } else {68          document.getElementById("status_role").className =69            "displayStatusRole";70          openPage = false;71          openUserPage = "";72        }73      }74    }75 }76 ...Using AI Code Generation
1const { remote } = require('webdriverio');2const opts = {3    capabilities: {4    }5}6async function main() {7    const client = await remote(opts);8}9main()10{11  "scripts": {12  },13  "dependencies": {14  }15}Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3  desiredCapabilities: {4  }5};6  .remote(options)7  .init()8  .then(function() {9  })10  .then(function() {11    return this.pause(1000);12  })13  .then(function() {14  })15  .then(function() {16    return this.pause(1000);17  })18  .end();19var webdriverio = require('webdriverio');20var options = {21  desiredCapabilities: {22  }23};24  .remote(options)25  .init()26  .then(function() {27  })28  .then(function() {29    return this.pause(1000);30  })31  .then(function() {32  })33  .then(function() {34    return this.pause(1000);35  })36  .end();37var webdriverio = require('webdriverio');38var options = {39  desiredCapabilities: {Using AI Code Generation
1var wd = require('wd');2var desiredCaps = {3}4driver.init(desiredCaps)5  .then(() => {6    return driver.openPage('myPageName')7  })8  .then(() => {9    return driver.elementByAccessibilityId('myPageName')10  })11  .then((element) => {12    return driver.elementById(element.value)13  })14  .then((element) => {15  })16  .then((element) => {17    return driver.elementById(element.value)18  })19  .then((element) => {20  })21  .then((element) => {22    return driver.elementById(element.value)23  })24  .then((element) => {25  })26  .then((element) => {27    return driver.elementById(element.value)28  })29  .then((element) => {30  })31  .then((element) => {32    return driver.elementById(element.value)33  })34  .then((element) => {35  })36  .then((element) => {37    return driver.elementById(element.value)38  })39  .then((element) => {40  })41  .then((element) => {42    return driver.elementById(element.value)43  })44  .then((element) => {45  })46  .then((element) => {47    return driver.elementById(element.value)48  })49  .then((element) => {Using AI Code Generation
1const wdio = require("webdriverio");2const opts = require("./wdio.conf.js").config;3const assert = require("assert");4async function main() {5  const client = await wdio.remote(opts);6  try {7    const response = await client.openPage({8    });9    console.log(response);10  } catch (err) {11    console.log(err);12  }13}14main();15exports.config = {16    {17    },18  mochaOpts: {19  },20};Using AI Code Generation
1const { openPage } = require('appium-xcuitest-driver').commands;2const { openPage } = require('appium-xcuitest-driver').commands;3const { openPage } = require('appium-xcuitest-driver').commands;4const { openPage } = require('appium-xcuitest-driver').commands;5const { openPage } = require('appium-xcuitest-driver').commands;6const { openPage } = require('appium-xcuitest-driver').commands;7const { openPage } = require('appium-xcuitest-driver').commands;8const { openPage } = require('appium-xcuitest-driver').commands;9const { openPage } = require('appium-xcuitest-driver').commands;10const { openPage } = require('appium-xcuitest-driver').commands;11const { openPage } = require('appium-xcuitest-driver').commands;12const { openPage } = require('appium-xcuitest-driver').commands;Using AI Code Generation
1const { openPage } = require('appium-xcuitest-driver/lib/commands/web');2Appium version (or git revision) that exhibits the issue: 1.13.03Last Appium version that did not exhibit the issue (if applicable): N/A4Node.js version (unless using Appium.app|exe): 11.10.05    at Object.setUrl (/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/commands/web.js:17:11)6    at XCUITestDriver.callee$0$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:327:24)7    at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:62:40)8    at Generator.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.jsLearn 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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
