forked from mirrors/gecko-dev
		
	 a36a923325
			
		
	
	
		a36a923325
		
	
	
	
	
		
			
			Using head-*.js as the name of a test helper makes it automagically visible from all tests in the suite thanks to the import-headjs-globals.js plugin. Renaming them to helper-*.js forces to explicitly import them and get linting errors if we forgot to do so. All helpers have been consistently renamed to helper-*.js. One method from the collapsibilities helper has been moved to the main head.js, because it doesn't have any relation with collapsing target panes. All ADB tests also now check that ADB is not running before starting. I tried forcing ADB to stop in this case, but we can't kill it from the tests apparently, so the only option is for the user to manually kill the process. At least now we get a somewhat helpful error message, and no timeout. Differential Revision: https://phabricator.services.mozilla.com/D15465 --HG-- rename : devtools/client/aboutdebugging-new/test/browser/head-addons-script.js => devtools/client/aboutdebugging-new/test/browser/helper-addons.js rename : devtools/client/aboutdebugging-new/test/browser/debug-target-pane_collapsibilities_head.js => devtools/client/aboutdebugging-new/test/browser/helper-collapsibilities.js rename : devtools/client/aboutdebugging-new/test/browser/head-mocks.js => devtools/client/aboutdebugging-new/test/browser/helper-mocks.js rename : devtools/client/aboutdebugging-new/test/browser/head-serviceworker.js => devtools/client/aboutdebugging-new/test/browser/helper-serviceworker.js rename : devtools/client/aboutdebugging-new/test/browser/mocks/head-client-wrapper-mock.js => devtools/client/aboutdebugging-new/test/browser/mocks/helper-client-wrapper-mock.js rename : devtools/client/aboutdebugging-new/test/browser/mocks/head-runtime-client-factory-mock.js => devtools/client/aboutdebugging-new/test/browser/mocks/helper-runtime-client-factory-mock.js rename : devtools/client/aboutdebugging-new/test/browser/mocks/head-usb-runtimes-mock.js => devtools/client/aboutdebugging-new/test/browser/mocks/helper-usb-runtimes-mock.js extra : moz-landing-system : lando
		
			
				
	
	
		
			89 lines
		
	
	
	
		
			3.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			89 lines
		
	
	
	
		
			3.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /* Any copyright is dedicated to the Public Domain.
 | |
|    http://creativecommons.org/publicdomain/zero/1.0/ */
 | |
| 
 | |
| "use strict";
 | |
| 
 | |
| /* import-globals-from helper-collapsibilities.js */
 | |
| Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-collapsibilities.js", this);
 | |
| 
 | |
| /**
 | |
|  * Check that navigating from This Firefox to Connect and back to This Firefox works and
 | |
|  * does not leak.
 | |
|  */
 | |
| 
 | |
| const TAB_URL_1 = "data:text/html,<title>TAB1</title>";
 | |
| const TAB_URL_2 = "data:text/html,<title>TAB2</title>";
 | |
| 
 | |
| add_task(async function() {
 | |
|   info("Force all debug target panes to be expanded");
 | |
|   prepareCollapsibilitiesTest();
 | |
| 
 | |
|   const { document, tab, window } = await openAboutDebugging();
 | |
|   const AboutDebugging = window.AboutDebugging;
 | |
| 
 | |
|   const connectSidebarItem = findSidebarItemByText("Connect", document);
 | |
|   const connectLink = connectSidebarItem.querySelector(".js-sidebar-link");
 | |
|   ok(connectSidebarItem, "Found the Connect sidebar item");
 | |
| 
 | |
|   const thisFirefoxSidebarItem = findSidebarItemByText("This Firefox", document);
 | |
|   const thisFirefoxLink = thisFirefoxSidebarItem.querySelector(".js-sidebar-link");
 | |
|   ok(thisFirefoxSidebarItem, "Found the ThisFirefox sidebar item");
 | |
|   ok(isSidebarItemSelected(thisFirefoxSidebarItem),
 | |
|     "ThisFirefox sidebar item is selected by default");
 | |
| 
 | |
|   info("Open a new background tab TAB1");
 | |
|   const backgroundTab1 = await addTab(TAB_URL_1, { background: true });
 | |
| 
 | |
|   info("Wait for the tab to appear in the debug targets with the correct name");
 | |
|   await waitUntil(() => findDebugTargetByText("TAB1", document));
 | |
| 
 | |
|   await waitForRequestsToSettle(AboutDebugging.store);
 | |
|   info("Click on the Connect item in the sidebar");
 | |
|   connectLink.click();
 | |
| 
 | |
|   info("Wait until Connect page is displayed");
 | |
|   await waitUntil(() => document.querySelector(".js-connect-page"));
 | |
|   // we need to wait here because the sidebar isn't updated after mounting the page
 | |
|   info("Wait until Connect sidebar item is selected");
 | |
|   await waitUntil(() => isSidebarItemSelected(connectSidebarItem));
 | |
|   ok(!document.querySelector(".js-runtime-page"), "Runtime page no longer rendered");
 | |
| 
 | |
|   info("Open a new tab which should be listed when we go back to This Firefox");
 | |
|   const backgroundTab2 = await addTab(TAB_URL_2, { background: true });
 | |
| 
 | |
|   info("Click on the ThisFirefox item in the sidebar");
 | |
|   const requestsSuccess = waitForRequestsSuccess(window);
 | |
|   thisFirefoxLink.click();
 | |
| 
 | |
|   info("Wait for all target requests to complete");
 | |
|   await requestsSuccess;
 | |
| 
 | |
|   info("Wait until ThisFirefox page is displayed");
 | |
|   await waitUntil(() => document.querySelector(".js-runtime-page"));
 | |
|   ok(isSidebarItemSelected(thisFirefoxSidebarItem),
 | |
|     "ThisFirefox sidebar item is selected again");
 | |
|   ok(!document.querySelector(".js-connect-page"), "Connect page no longer rendered");
 | |
| 
 | |
|   info("TAB2 should already be displayed in the debug targets");
 | |
|   await waitUntil(() => findDebugTargetByText("TAB2", document));
 | |
| 
 | |
|   info("Remove first background tab");
 | |
|   await removeTab(backgroundTab1);
 | |
| 
 | |
|   info("Check TAB1 disappears, meaning ThisFirefox client is correctly connected");
 | |
|   await waitUntil(() => !findDebugTargetByText("TAB1", document));
 | |
| 
 | |
|   info("Remove second background tab");
 | |
|   await removeTab(backgroundTab2);
 | |
| 
 | |
|   info("Check TAB2 disappears, meaning ThisFirefox client is correctly connected");
 | |
|   await waitUntil(() => !findDebugTargetByText("TAB2", document));
 | |
| 
 | |
|   await waitForRequestsToSettle(AboutDebugging.store);
 | |
| 
 | |
|   await removeTab(tab);
 | |
| });
 | |
| 
 | |
| function isSidebarItemSelected(item) {
 | |
|   return item.classList.contains("js-sidebar-item-selected");
 | |
| }
 |