forked from mirrors/gecko-dev
		
	 1afdfc8b8a
			
		
	
	
		1afdfc8b8a
		
	
	
	
	
		
			
			As expected, the try job flagged a bunch of test failures when flipping the default `delayedApply` pref to `true`. Some of these failures are legitimate issues: - When creating a new folder in the tree under "Location", renaming the folder doesn't update its name in the Location field. - When right clicking a bookmark in the sidebar, and creating a new folder, the folder doesn't get placed before the bookmark, i.e. the insertion point is ignored. And as you pointed out, tags were being wiped out on blur in the Star/Toolbar panels. These issues have been fixed. The rest of the failures have been fixed in one of these ways: - Update the test to pass regardless of `delayedApply` setting. This was the preferred method. - Force the test to use instant apply. This was only done for tests that have an existing delayed apply counterpart. - Force the entire test suite to use instant apply. This was only done for one file, namely `browser_bookmark_popup.js`. I'll file a bug to spin off a delayed apply version of this suite. try job with `delayedApply` enabled: https://treeherder.mozilla.org/jobs?repo=try&revision=50e9cdb65feaec07c9519e928caf62042c3df9a4 try job with `delayedApply` disabled: https://treeherder.mozilla.org/jobs?repo=try&revision=1102b5076a79bf08a0e4b073fdf369af97a16ef7 Differential Revision: https://phabricator.services.mozilla.com/D168690
		
			
				
	
	
		
			260 lines
		
	
	
	
		
			8.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			260 lines
		
	
	
	
		
			8.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /* Any copyright is dedicated to the Public Domain.
 | |
|  * https://creativecommons.org/publicdomain/zero/1.0/ */
 | |
| 
 | |
| "use strict";
 | |
| 
 | |
| add_task(async function test() {
 | |
|   // We use an extension that shows a page action. We must add this additional
 | |
|   // action because otherwise the meatball menu would not appear as an overflow
 | |
|   // for a single action.
 | |
|   let extension = ExtensionTestUtils.loadExtension({
 | |
|     manifest: {
 | |
|       name: "Test contextMenu",
 | |
|       page_action: { show_matches: ["<all_urls>"] },
 | |
|     },
 | |
| 
 | |
|     useAddonManager: "temporary",
 | |
|   });
 | |
| 
 | |
|   await extension.startup();
 | |
|   let actionId = ExtensionCommon.makeWidgetId(extension.id);
 | |
| 
 | |
|   let win = await BrowserTestUtils.openNewBrowserWindow();
 | |
|   await SimpleTest.promiseFocus(win);
 | |
|   Assert.greater(win.outerWidth, 700, "window is bigger than 700px");
 | |
|   BrowserTestUtils.loadURIString(
 | |
|     win.gBrowser,
 | |
|     "data:text/html,<h1>A Page</h1>"
 | |
|   );
 | |
|   await BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
 | |
| 
 | |
|   // The pageAction implementation enables the button at the next animation
 | |
|   // frame, so before we look for the button we should wait one animation frame
 | |
|   // as well.
 | |
|   await promiseAnimationFrame(win);
 | |
| 
 | |
|   info("Check page action buttons are visible, the meatball button is not");
 | |
|   let addonButton = win.BrowserPageActions.urlbarButtonNodeForActionID(
 | |
|     actionId
 | |
|   );
 | |
|   Assert.ok(BrowserTestUtils.is_visible(addonButton));
 | |
|   let starButton = win.BrowserPageActions.urlbarButtonNodeForActionID(
 | |
|     "bookmark"
 | |
|   );
 | |
|   Assert.ok(BrowserTestUtils.is_visible(starButton));
 | |
|   let meatballButton = win.document.getElementById("pageActionButton");
 | |
|   Assert.ok(!BrowserTestUtils.is_visible(meatballButton));
 | |
| 
 | |
|   info(
 | |
|     "Shrink the window, check page action buttons are not visible, the meatball menu is visible"
 | |
|   );
 | |
|   let originalOuterWidth = win.outerWidth;
 | |
|   await promiseStableResize(500, win);
 | |
|   Assert.ok(!BrowserTestUtils.is_visible(addonButton));
 | |
|   Assert.ok(!BrowserTestUtils.is_visible(starButton));
 | |
|   Assert.ok(BrowserTestUtils.is_visible(meatballButton));
 | |
| 
 | |
|   info(
 | |
|     "Remove the extension, check the only page action button is visible, the meatball menu is not visible"
 | |
|   );
 | |
|   let promiseUninstalled = promiseAddonUninstalled(extension.id);
 | |
|   await extension.unload();
 | |
|   await promiseUninstalled;
 | |
|   Assert.ok(BrowserTestUtils.is_visible(starButton));
 | |
|   Assert.ok(!BrowserTestUtils.is_visible(meatballButton));
 | |
|   Assert.deepEqual(
 | |
|     win.BrowserPageActions.urlbarButtonNodeForActionID(actionId),
 | |
|     null
 | |
|   );
 | |
| 
 | |
|   await promiseStableResize(originalOuterWidth, win);
 | |
|   await BrowserTestUtils.closeWindow(win);
 | |
| });
 | |
| 
 | |
| add_task(async function bookmark() {
 | |
|   // We use an extension that shows a page action. We must add this additional
 | |
|   // action because otherwise the meatball menu would not appear as an overflow
 | |
|   // for a single action.
 | |
|   let extension = ExtensionTestUtils.loadExtension({
 | |
|     manifest: {
 | |
|       name: "Test contextMenu",
 | |
|       page_action: { show_matches: ["<all_urls>"] },
 | |
|     },
 | |
| 
 | |
|     useAddonManager: "temporary",
 | |
|   });
 | |
| 
 | |
|   await extension.startup();
 | |
|   const url = "data:text/html,<h1>A Page</h1>";
 | |
|   let win = await BrowserTestUtils.openNewBrowserWindow();
 | |
|   await SimpleTest.promiseFocus(win);
 | |
|   BrowserTestUtils.loadURIString(win.gBrowser, url);
 | |
|   await BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
 | |
| 
 | |
|   // The pageAction implementation enables the button at the next animation
 | |
|   // frame, so before we look for the button we should wait one animation frame
 | |
|   // as well.
 | |
|   await promiseAnimationFrame(win);
 | |
| 
 | |
|   info("Shrink the window if necessary, check the meatball menu is visible");
 | |
|   let originalOuterWidth = win.outerWidth;
 | |
|   await promiseStableResize(500, win);
 | |
| 
 | |
|   let meatballButton = win.document.getElementById("pageActionButton");
 | |
|   Assert.ok(BrowserTestUtils.is_visible(meatballButton));
 | |
| 
 | |
|   // Open the panel.
 | |
|   await promisePageActionPanelOpen(win);
 | |
| 
 | |
|   // The bookmark button should read "Bookmark Current Tab…" and not be starred.
 | |
|   let bookmarkButton = win.document.getElementById("pageAction-panel-bookmark");
 | |
|   await TestUtils.waitForCondition(
 | |
|     () => bookmarkButton.label === "Bookmark Current Tab…"
 | |
|   );
 | |
|   Assert.ok(!bookmarkButton.hasAttribute("starred"));
 | |
| 
 | |
|   // Click the button.
 | |
|   let hiddenPromise = promisePageActionPanelHidden(win);
 | |
|   let showPromise = BrowserTestUtils.waitForPopupEvent(
 | |
|     win.StarUI.panel,
 | |
|     "shown"
 | |
|   );
 | |
|   EventUtils.synthesizeMouseAtCenter(bookmarkButton, {}, win);
 | |
|   await hiddenPromise;
 | |
|   await showPromise;
 | |
|   win.StarUI.panel.hidePopup();
 | |
| 
 | |
|   // Open the panel again.
 | |
|   await promisePageActionPanelOpen(win);
 | |
| 
 | |
|   // The bookmark button should now read "Edit This Bookmark…" and be starred.
 | |
|   await TestUtils.waitForCondition(
 | |
|     () => bookmarkButton.label === "Edit This Bookmark…"
 | |
|   );
 | |
|   Assert.ok(bookmarkButton.hasAttribute("starred"));
 | |
|   Assert.equal(bookmarkButton.getAttribute("starred"), "true");
 | |
| 
 | |
|   // Click it again.
 | |
|   hiddenPromise = promisePageActionPanelHidden(win);
 | |
|   showPromise = BrowserTestUtils.waitForPopupEvent(win.StarUI.panel, "shown");
 | |
|   EventUtils.synthesizeMouseAtCenter(bookmarkButton, {}, win);
 | |
|   await hiddenPromise;
 | |
|   await showPromise;
 | |
| 
 | |
|   let onItemRemovedPromise = PlacesTestUtils.waitForNotification(
 | |
|     "bookmark-removed",
 | |
|     events => events.some(event => event.url == url)
 | |
|   );
 | |
| 
 | |
|   // Click the remove-bookmark button in the panel.
 | |
|   win.StarUI._element("editBookmarkPanelRemoveButton").click();
 | |
| 
 | |
|   // Wait for the bookmark to be removed before continuing.
 | |
|   await onItemRemovedPromise;
 | |
| 
 | |
|   // Open the panel again.
 | |
|   await promisePageActionPanelOpen(win);
 | |
| 
 | |
|   // The bookmark button should read "Bookmark Current Tab…" and not be starred.
 | |
|   await TestUtils.waitForCondition(
 | |
|     () => bookmarkButton.label === "Bookmark Current Tab…"
 | |
|   );
 | |
|   Assert.ok(!bookmarkButton.hasAttribute("starred"));
 | |
| 
 | |
|   // Done.
 | |
|   hiddenPromise = promisePageActionPanelHidden();
 | |
|   win.BrowserPageActions.panelNode.hidePopup();
 | |
|   await hiddenPromise;
 | |
| 
 | |
|   info("Remove the extension");
 | |
|   let promiseUninstalled = promiseAddonUninstalled(extension.id);
 | |
|   await extension.unload();
 | |
|   await promiseUninstalled;
 | |
| 
 | |
|   await promiseStableResize(originalOuterWidth, win);
 | |
|   await BrowserTestUtils.closeWindow(win);
 | |
| });
 | |
| 
 | |
| add_task(async function test_disabledPageAction_hidden_in_protonOverflowMenu() {
 | |
|   // Make sure the overflow menu urlbar button is visible (indipendently from
 | |
|   // the current size of the Firefox window).
 | |
|   BrowserPageActions.mainButtonNode.style.visibility = "visible";
 | |
|   registerCleanupFunction(() => {
 | |
|     BrowserPageActions.mainButtonNode.style.removeProperty("visibility");
 | |
|   });
 | |
| 
 | |
|   const extension = ExtensionTestUtils.loadExtension({
 | |
|     manifest: { page_action: {} },
 | |
|     async background() {
 | |
|       const { browser } = this;
 | |
|       const [tab] = await browser.tabs.query({
 | |
|         active: true,
 | |
|         currentWindow: true,
 | |
|       });
 | |
|       browser.test.assertTrue(tab, "Got an active tab as expected");
 | |
|       browser.test.onMessage.addListener(async msg => {
 | |
|         switch (msg) {
 | |
|           case "show-pageAction":
 | |
|             await browser.pageAction.show(tab.id);
 | |
|             break;
 | |
|           case "hide-pageAction":
 | |
|             await browser.pageAction.hide(tab.id);
 | |
|             break;
 | |
|           default:
 | |
|             browser.test.fail(`Unexpected message received: ${msg}`);
 | |
|         }
 | |
|         browser.test.sendMessage(`${msg}:done`);
 | |
|       });
 | |
|     },
 | |
|   });
 | |
| 
 | |
|   // eslint-disable-next-line @microsoft/sdl/no-insecure-url
 | |
|   await BrowserTestUtils.withNewTab("http://example.com", async browser => {
 | |
|     const win = browser.ownerGlobal;
 | |
|     const promisePageActionPanelClosed = async () => {
 | |
|       let popupHiddenPromise = promisePageActionPanelHidden(win);
 | |
|       win.BrowserPageActions.panelNode.hidePopup();
 | |
|       await popupHiddenPromise;
 | |
|     };
 | |
| 
 | |
|     await extension.startup();
 | |
|     const widgetId = ExtensionCommon.makeWidgetId(extension.id);
 | |
| 
 | |
|     info(
 | |
|       "Show pageAction and verify it is visible in the urlbar overflow menu"
 | |
|     );
 | |
|     extension.sendMessage("show-pageAction");
 | |
|     await extension.awaitMessage("show-pageAction:done");
 | |
|     await promisePageActionPanelOpen(win);
 | |
|     let pageActionNode = win.BrowserPageActions.panelButtonNodeForActionID(
 | |
|       widgetId
 | |
|     );
 | |
|     ok(
 | |
|       pageActionNode && BrowserTestUtils.is_visible(pageActionNode),
 | |
|       "enabled pageAction should be visible in the urlbar overflow menu"
 | |
|     );
 | |
| 
 | |
|     info("Hide pageAction and verify it is hidden in the urlbar overflow menu");
 | |
|     extension.sendMessage("hide-pageAction");
 | |
|     await extension.awaitMessage("hide-pageAction:done");
 | |
| 
 | |
|     await BrowserTestUtils.waitForCondition(
 | |
|       () => !win.BrowserPageActions.panelButtonNodeForActionID(widgetId),
 | |
|       "Wait for the disabled pageAction to be removed from the urlbar overflow menu"
 | |
|     );
 | |
| 
 | |
|     await promisePageActionPanelClosed();
 | |
| 
 | |
|     info("Reopen the urlbar overflow menu");
 | |
|     await promisePageActionPanelOpen(win);
 | |
|     ok(
 | |
|       !win.BrowserPageActions.panelButtonNodeForActionID(widgetId),
 | |
|       "Disabled pageAction is still removed as expected"
 | |
|     );
 | |
| 
 | |
|     await promisePageActionPanelClosed();
 | |
|     await extension.unload();
 | |
|   });
 | |
| 
 | |
|   await SpecialPowers.popPrefEnv();
 | |
| });
 |