mirror of
https://github.com/zen-browser/desktop.git
synced 2025-09-05 19:08:18 +00:00
test: Added drag and drop automatic testing, b=no-bug, c=tests, scripts, tabs
This commit is contained in:
2
l10n
2
l10n
Submodule l10n updated: 7435b28bdf...fcd32a777e
@@ -37,9 +37,6 @@
|
||||
- name: zen.view.grey-out-inactive-windows
|
||||
value: true
|
||||
|
||||
- name: zen.view.show-newtab-button-border-top
|
||||
value: false
|
||||
|
||||
- name: zen.view.show-newtab-button-top
|
||||
value: true
|
||||
|
||||
|
@@ -4,7 +4,6 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@@ -32,7 +31,8 @@ def main():
|
||||
|
||||
def run_mach_with_paths(test_paths):
|
||||
command = ['./mach', 'mochitest'] + other_args + test_paths
|
||||
subprocess.run(command, check=True)
|
||||
# Replace the current process with the mach command
|
||||
os.execvp(command[0], command)
|
||||
|
||||
if path in ("", "all"):
|
||||
test_dirs = [p for p in Path("zen/tests").iterdir() if p.is_dir()]
|
||||
|
@@ -7,6 +7,7 @@ BROWSER_CHROME_MANIFESTS += [
|
||||
"container_essentials/browser.toml",
|
||||
"glance/browser.toml",
|
||||
"pinned/browser.toml",
|
||||
"tabs/browser.toml",
|
||||
"urlbar/browser.toml",
|
||||
"welcome/browser.toml",
|
||||
"workspaces/browser.toml",
|
||||
|
14
src/zen/tests/tabs/browser.toml
Normal file
14
src/zen/tests/tabs/browser.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
[DEFAULT]
|
||||
support-files = [
|
||||
"head.js",
|
||||
]
|
||||
|
||||
["browser_drag_drop_vertical.js"]
|
||||
tags = [
|
||||
"drag-drop",
|
||||
"vertical-tabs"
|
||||
]
|
178
src/zen/tests/tabs/browser_drag_drop_vertical.js
Normal file
178
src/zen/tests/tabs/browser_drag_drop_vertical.js
Normal file
@@ -0,0 +1,178 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
https://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
'use strict';
|
||||
|
||||
const URL1 = 'data:text/plain,tab1';
|
||||
const URL2 = 'data:text/plain,tab2';
|
||||
const URL3 = 'data:text/plain,tab3';
|
||||
|
||||
const threshold = Math.min(
|
||||
1.0,
|
||||
Math.max(0.5, Services.prefs.getIntPref('browser.tabs.dragDrop.moveOverThresholdPercent') / 100) +
|
||||
0.01
|
||||
);
|
||||
|
||||
/**
|
||||
* Virtually drag and drop a `source` element onto the `target` element,
|
||||
* offset by `clientX`, `clientY` pixels from the top-left of the viewport.
|
||||
*
|
||||
* @param {Element} source
|
||||
* @param {Element} target
|
||||
* @param {number} clientX
|
||||
* @param {number} clientY
|
||||
* @param {Window} win
|
||||
*/
|
||||
async function drop(source, target, clientX, clientY, win) {
|
||||
const tabMove = BrowserTestUtils.waitForEvent(source, 'TabMove');
|
||||
EventUtils.synthesizeDrop(source, target, null, 'move', win, win, {
|
||||
clientX,
|
||||
clientY,
|
||||
});
|
||||
await tabMove;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element} el
|
||||
* @returns {DOMRect}
|
||||
*/
|
||||
const bounds = (el) => window.windowUtils.getBoundsWithoutFlushing(el);
|
||||
|
||||
/**
|
||||
* Virtually drag and drop one tab strip item after another.
|
||||
*
|
||||
* @param {Element} itemToDrag
|
||||
* @param {Element} itemToDropAfter
|
||||
* @param {Window} win
|
||||
*/
|
||||
async function dropAfter(itemToDrag, itemToDropAfter, win) {
|
||||
const sourceRect = bounds(itemToDrag);
|
||||
const rect = bounds(itemToDropAfter);
|
||||
|
||||
const midline = rect.left + 0.5 * rect.width;
|
||||
// Point where bottom edge of `itemToDrag` overlaps `itemToDropAfter` enough
|
||||
// for `itemToDrag` to come after.
|
||||
const afterPoint = Math.ceil(rect.top + threshold * rect.height);
|
||||
const dragTo = afterPoint - sourceRect.height / 2;
|
||||
await drop(itemToDrag, itemToDropAfter, midline, dragTo, win);
|
||||
}
|
||||
|
||||
/**
|
||||
* Virtually drag and drop one tab strip item before another.
|
||||
*
|
||||
* @param {Element} itemToDrag
|
||||
* @param {Element} itemToDropBefore
|
||||
* @param {Window} win
|
||||
*/
|
||||
async function dropBefore(itemToDrag, itemToDropBefore, win) {
|
||||
const sourceRect = bounds(itemToDrag);
|
||||
const rect = bounds(itemToDropBefore);
|
||||
|
||||
const midline = rect.left + 0.5 * rect.width;
|
||||
// Point where top edge of `itemToDrag` overlaps `itemToDropBefore` enough
|
||||
// for `itemToDrag` to come before.
|
||||
const beforePoint = Math.floor(rect.top + (1 - threshold) * rect.height);
|
||||
const dragTo = beforePoint + sourceRect.height / 2;
|
||||
await drop(itemToDrag, itemToDropBefore, midline, dragTo, win);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the tab strip can fit the test tabs without overflowing.
|
||||
*/
|
||||
async function ensureNotOverflowing() {
|
||||
const tabHeight = Number.parseFloat(
|
||||
getComputedStyle(gBrowser.tabs[0]).getPropertyValue('--tab-height-with-margin-padding')
|
||||
);
|
||||
const requiredTabSpace = tabHeight * gBrowser.tabs.length;
|
||||
const scrollboxWidth = gBrowser.tabContainer.arrowScrollbox.scrollSize;
|
||||
if (requiredTabSpace > scrollboxWidth) {
|
||||
// resize the window to ensure that the tabs will fit
|
||||
const increaseBy = requiredTabSpace - scrollboxWidth;
|
||||
info(`increasing window height by ${increaseBy} to fit tabs`);
|
||||
window.resizeBy(0, increaseBy);
|
||||
}
|
||||
|
||||
await BrowserTestUtils.waitForCondition(
|
||||
() => !gBrowser.tabContainer.arrowScrollbox.overflowing,
|
||||
'tabs scrollbox should not be overflowing',
|
||||
100,
|
||||
5
|
||||
);
|
||||
}
|
||||
|
||||
add_setup(async () => {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [['zen.view.show-newtab-button-top', false]],
|
||||
});
|
||||
|
||||
// Wait for sidebar animations to complete so that the position of the tab
|
||||
// strip does not adjust during the tests.
|
||||
await SidebarController.waitUntilStable();
|
||||
const tabToRemove = gBrowser.selectedTab;
|
||||
const [tab1, tab2, tab3] = await Promise.all([
|
||||
addTabTo(gBrowser, URL1),
|
||||
addTabTo(gBrowser, URL2),
|
||||
addTabTo(gBrowser, URL3),
|
||||
]);
|
||||
// remove the default new tab from the test window
|
||||
BrowserTestUtils.removeTab(tabToRemove);
|
||||
const emptyTab = gBrowser.tabs[0];
|
||||
|
||||
Assert.deepEqual(gBrowser.tabs, [emptyTab, tab1, tab2, tab3], "confirm tabs' starting order");
|
||||
|
||||
await ensureNotOverflowing();
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
// replace the default new tab in the test window
|
||||
await addTab('about:blank');
|
||||
|
||||
BrowserTestUtils.removeTab(tab1);
|
||||
BrowserTestUtils.removeTab(tab2);
|
||||
BrowserTestUtils.removeTab(tab3);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_basic_unpinned_vertical_ltr() {
|
||||
const [emptyTab, tab1, tab2, tab3] = gBrowser.tabs;
|
||||
|
||||
// Validate that dragging and dropping into the same position will result in
|
||||
// the tab not moving
|
||||
for (const tab of [tab1, tab2, tab3]) {
|
||||
EventUtils.synthesizeDrop(tab, tab, null, 'move', window, window, {});
|
||||
Assert.deepEqual(
|
||||
gBrowser.tabs,
|
||||
[emptyTab, tab1, tab2, tab3],
|
||||
"confirm that the tabs' order did not change"
|
||||
);
|
||||
}
|
||||
|
||||
// Validate that it's possible to drag and drop a tab forward
|
||||
await dropAfter(tab1, tab2, window);
|
||||
Assert.deepEqual(
|
||||
gBrowser.tabs,
|
||||
[tab2, tab1, tab3, emptyTab],
|
||||
'confirm that tab1 moved after tab2'
|
||||
);
|
||||
await dropAfter(tab1, tab3, window);
|
||||
Assert.deepEqual(
|
||||
gBrowser.tabs,
|
||||
[tab2, tab3, tab1, emptyTab],
|
||||
'confirm that tab1 moved after tab3'
|
||||
);
|
||||
|
||||
// Validate that it's possible to drag and drop a tab backward
|
||||
await dropBefore(tab1, tab3, window);
|
||||
Assert.deepEqual(
|
||||
gBrowser.tabs,
|
||||
[tab2, tab1, tab3, emptyTab],
|
||||
'confirm that tab1 moved before tab3'
|
||||
);
|
||||
await dropBefore(tab1, tab2, window);
|
||||
Assert.deepEqual(
|
||||
gBrowser.tabs,
|
||||
[tab1, tab2, tab3, emptyTab],
|
||||
'confirm that tab1 moved before tab2'
|
||||
);
|
||||
});
|
547
src/zen/tests/tabs/head.js
Normal file
547
src/zen/tests/tabs/head.js
Normal file
@@ -0,0 +1,547 @@
|
||||
const { TabGroupTestUtils } = ChromeUtils.importESModule(
|
||||
'resource://testing-common/TabGroupTestUtils.sys.mjs'
|
||||
);
|
||||
|
||||
function promiseTabLoadEvent(tab, url) {
|
||||
info('Wait tab event: load');
|
||||
|
||||
function handle(loadedUrl) {
|
||||
if (loadedUrl === 'about:blank' || (url && loadedUrl !== url)) {
|
||||
info(`Skipping spurious load event for ${loadedUrl}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
info('Tab event received: load');
|
||||
return true;
|
||||
}
|
||||
|
||||
let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, handle);
|
||||
|
||||
if (url) {
|
||||
BrowserTestUtils.startLoadingURIString(tab.linkedBrowser, url);
|
||||
}
|
||||
|
||||
return loaded;
|
||||
}
|
||||
|
||||
function updateTabContextMenu(tab) {
|
||||
let menu = document.getElementById('tabContextMenu');
|
||||
if (!tab) {
|
||||
tab = gBrowser.selectedTab;
|
||||
}
|
||||
var evt = new Event('');
|
||||
tab.dispatchEvent(evt);
|
||||
menu.openPopup(tab, 'end_after', 0, 0, true, false, evt);
|
||||
is(window.TabContextMenu.contextTab, tab, 'TabContextMenu context is the expected tab');
|
||||
menu.hidePopup();
|
||||
}
|
||||
|
||||
function triggerClickOn(target, options) {
|
||||
let promise = BrowserTestUtils.waitForEvent(target, 'click');
|
||||
if (AppConstants.platform == 'macosx') {
|
||||
options = {
|
||||
metaKey: options.ctrlKey,
|
||||
shiftKey: options.shiftKey,
|
||||
};
|
||||
}
|
||||
EventUtils.synthesizeMouseAtCenter(target, options);
|
||||
return promise;
|
||||
}
|
||||
|
||||
function triggerMiddleClickOn(target) {
|
||||
let promise = BrowserTestUtils.waitForEvent(target, 'click');
|
||||
EventUtils.synthesizeMouseAtCenter(target, { button: 1 });
|
||||
return promise;
|
||||
}
|
||||
|
||||
async function addTab(url = 'http://mochi.test:8888/', params) {
|
||||
return addTabTo(gBrowser, url, params);
|
||||
}
|
||||
|
||||
async function addTabTo(targetBrowser, url = 'http://mochi.test:8888/', params = {}) {
|
||||
params.skipAnimation = true;
|
||||
const tab = BrowserTestUtils.addTab(targetBrowser, url, params);
|
||||
const browser = targetBrowser.getBrowserForTab(tab);
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
return tab;
|
||||
}
|
||||
|
||||
async function addMediaTab() {
|
||||
const PAGE =
|
||||
'https://example.com/browser/browser/components/tabbrowser/test/browser/tabs/file_mediaPlayback.html';
|
||||
const tab = BrowserTestUtils.addTab(gBrowser, PAGE, { skipAnimation: true });
|
||||
const browser = gBrowser.getBrowserForTab(tab);
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
return tab;
|
||||
}
|
||||
|
||||
function muted(tab) {
|
||||
return tab.linkedBrowser.audioMuted;
|
||||
}
|
||||
|
||||
function activeMediaBlocked(tab) {
|
||||
return tab.activeMediaBlocked;
|
||||
}
|
||||
|
||||
async function toggleMuteAudio(tab, expectMuted) {
|
||||
let mutedPromise = get_wait_for_mute_promise(tab, expectMuted);
|
||||
tab.toggleMuteAudio();
|
||||
await mutedPromise;
|
||||
}
|
||||
|
||||
async function pressIcon(icon) {
|
||||
let tooltip = document.getElementById('tabbrowser-tab-tooltip');
|
||||
await hover_icon(icon, tooltip);
|
||||
EventUtils.synthesizeMouseAtCenter(icon, { button: 0 });
|
||||
leave_icon(icon);
|
||||
}
|
||||
|
||||
async function wait_for_tab_playing_event(tab, expectPlaying) {
|
||||
if (tab.soundPlaying == expectPlaying) {
|
||||
ok(true, 'The tab should ' + (expectPlaying ? '' : 'not ') + 'be playing');
|
||||
return true;
|
||||
}
|
||||
return BrowserTestUtils.waitForEvent(tab, 'TabAttrModified', false, (event) => {
|
||||
if (event.detail.changed.includes('soundplaying')) {
|
||||
is(
|
||||
tab.hasAttribute('soundplaying'),
|
||||
expectPlaying,
|
||||
'The tab should ' + (expectPlaying ? '' : 'not ') + 'be playing'
|
||||
);
|
||||
is(
|
||||
tab.soundPlaying,
|
||||
expectPlaying,
|
||||
'The tab should ' + (expectPlaying ? '' : 'not ') + 'be playing'
|
||||
);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
async function wait_for_tab_media_blocked_event(tab, expectMediaBlocked) {
|
||||
if (tab.activeMediaBlocked == expectMediaBlocked) {
|
||||
ok(true, 'The tab should ' + (expectMediaBlocked ? '' : 'not ') + 'be activemedia-blocked');
|
||||
return true;
|
||||
}
|
||||
return BrowserTestUtils.waitForEvent(tab, 'TabAttrModified', false, (event) => {
|
||||
if (event.detail.changed.includes('activemedia-blocked')) {
|
||||
is(
|
||||
tab.hasAttribute('activemedia-blocked'),
|
||||
expectMediaBlocked,
|
||||
'The tab should ' + (expectMediaBlocked ? '' : 'not ') + 'be activemedia-blocked'
|
||||
);
|
||||
is(
|
||||
tab.activeMediaBlocked,
|
||||
expectMediaBlocked,
|
||||
'The tab should ' + (expectMediaBlocked ? '' : 'not ') + 'be activemedia-blocked'
|
||||
);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
async function is_audio_playing(tab) {
|
||||
let browser = tab.linkedBrowser;
|
||||
let isPlaying = await SpecialPowers.spawn(browser, [], async function () {
|
||||
let audio = content.document.querySelector('audio');
|
||||
return !audio.paused;
|
||||
});
|
||||
return isPlaying;
|
||||
}
|
||||
|
||||
async function play(tab, expectPlaying = true) {
|
||||
let browser = tab.linkedBrowser;
|
||||
await SpecialPowers.spawn(browser, [], async function () {
|
||||
let audio = content.document.querySelector('audio');
|
||||
audio.play();
|
||||
});
|
||||
|
||||
// If the tab has already been muted, it means the tab won't get soundplaying,
|
||||
// so we don't need to check this attribute.
|
||||
if (browser.audioMuted) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (expectPlaying) {
|
||||
await wait_for_tab_playing_event(tab, true);
|
||||
} else {
|
||||
await wait_for_tab_media_blocked_event(tab, true);
|
||||
}
|
||||
}
|
||||
|
||||
function disable_non_test_mouse(disable) {
|
||||
let utils = window.windowUtils;
|
||||
utils.disableNonTestMouseEvents(disable);
|
||||
}
|
||||
|
||||
function hover_icon(icon, tooltip) {
|
||||
disable_non_test_mouse(true);
|
||||
|
||||
let popupShownPromise = BrowserTestUtils.waitForEvent(tooltip, 'popupshown');
|
||||
EventUtils.synthesizeMouse(icon, 1, 1, { type: 'mouseover' });
|
||||
EventUtils.synthesizeMouse(icon, 2, 2, { type: 'mousemove' });
|
||||
EventUtils.synthesizeMouse(icon, 3, 3, { type: 'mousemove' });
|
||||
EventUtils.synthesizeMouse(icon, 4, 4, { type: 'mousemove' });
|
||||
return popupShownPromise;
|
||||
}
|
||||
|
||||
function leave_icon(icon) {
|
||||
EventUtils.synthesizeMouse(icon, 0, 0, { type: 'mouseout' });
|
||||
EventUtils.synthesizeMouseAtCenter(document.documentElement, {
|
||||
type: 'mousemove',
|
||||
});
|
||||
EventUtils.synthesizeMouseAtCenter(document.documentElement, {
|
||||
type: 'mousemove',
|
||||
});
|
||||
EventUtils.synthesizeMouseAtCenter(document.documentElement, {
|
||||
type: 'mousemove',
|
||||
});
|
||||
|
||||
disable_non_test_mouse(false);
|
||||
}
|
||||
|
||||
// The set of tabs which have ever had their mute state changed.
|
||||
// Used to determine whether the tab should have a muteReason value.
|
||||
let everMutedTabs = new WeakSet();
|
||||
|
||||
function get_wait_for_mute_promise(tab, expectMuted) {
|
||||
return BrowserTestUtils.waitForEvent(tab, 'TabAttrModified', false, (event) => {
|
||||
if (
|
||||
event.detail.changed.includes('muted') ||
|
||||
event.detail.changed.includes('activemedia-blocked')
|
||||
) {
|
||||
is(
|
||||
tab.hasAttribute('muted'),
|
||||
expectMuted,
|
||||
'The tab should ' + (expectMuted ? '' : 'not ') + 'be muted'
|
||||
);
|
||||
is(
|
||||
tab.muted,
|
||||
expectMuted,
|
||||
'The tab muted property ' + (expectMuted ? '' : 'not ') + 'be true'
|
||||
);
|
||||
|
||||
if (expectMuted || everMutedTabs.has(tab)) {
|
||||
everMutedTabs.add(tab);
|
||||
is(tab.muteReason, null, 'The tab should have a null muteReason value');
|
||||
} else {
|
||||
is(tab.muteReason, undefined, 'The tab should have an undefined muteReason value');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
async function test_mute_tab(tab, icon, expectMuted) {
|
||||
let mutedPromise = get_wait_for_mute_promise(tab, expectMuted);
|
||||
|
||||
let activeTab = gBrowser.selectedTab;
|
||||
|
||||
let tooltip = document.getElementById('tabbrowser-tab-tooltip');
|
||||
|
||||
await hover_icon(icon, tooltip);
|
||||
EventUtils.synthesizeMouseAtCenter(icon, { button: 0 });
|
||||
leave_icon(icon);
|
||||
|
||||
is(
|
||||
gBrowser.selectedTab,
|
||||
activeTab,
|
||||
'Clicking on mute should not change the currently selected tab'
|
||||
);
|
||||
|
||||
// If the audio is playing, we should check whether clicking on icon affects
|
||||
// the media element's playing state.
|
||||
let isAudioPlaying = await is_audio_playing(tab);
|
||||
if (isAudioPlaying) {
|
||||
await wait_for_tab_playing_event(tab, !expectMuted);
|
||||
}
|
||||
|
||||
return mutedPromise;
|
||||
}
|
||||
|
||||
async function dragAndDrop(
|
||||
tab1,
|
||||
tab2,
|
||||
copy = false,
|
||||
destWindow = window,
|
||||
afterTab = true,
|
||||
origWindow = window
|
||||
) {
|
||||
let rect = tab2.getBoundingClientRect();
|
||||
let event = {
|
||||
ctrlKey: copy,
|
||||
altKey: copy,
|
||||
clientX: rect.left + rect.width / 2 + (afterTab ? 1 : -1),
|
||||
clientY: rect.top + rect.height / 2,
|
||||
};
|
||||
|
||||
if (destWindow != origWindow) {
|
||||
// Make sure that both tab1 and tab2 are visible
|
||||
origWindow.focus();
|
||||
origWindow.moveTo(rect.left, rect.top + rect.height * 3);
|
||||
}
|
||||
|
||||
let originalIndex = tab1.elementIndex;
|
||||
EventUtils.synthesizeDrop(
|
||||
tab1,
|
||||
tab2,
|
||||
null,
|
||||
copy ? 'copy' : 'move',
|
||||
origWindow,
|
||||
destWindow,
|
||||
event
|
||||
);
|
||||
// Ensure dnd suppression is cleared.
|
||||
EventUtils.synthesizeMouseAtCenter(tab2, { type: 'mouseup' }, destWindow);
|
||||
if (!copy && destWindow == origWindow) {
|
||||
await BrowserTestUtils.waitForCondition(() => {
|
||||
return tab1.elementIndex != originalIndex;
|
||||
}, 'Waiting for tab position to be updated');
|
||||
} else if (destWindow != origWindow) {
|
||||
await BrowserTestUtils.waitForCondition(() => tab1.closing, 'Waiting for tab closing');
|
||||
}
|
||||
}
|
||||
|
||||
function getUrl(tab) {
|
||||
return tab.linkedBrowser.currentURI.spec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a xul:browser and makes sure that the remoteTypes for the browser in
|
||||
* both the parent and the child processes are the same.
|
||||
*
|
||||
* @param {xul:browser} browser
|
||||
* A xul:browser.
|
||||
* @param {string} expectedRemoteType
|
||||
* The expected remoteType value for the browser in both the parent
|
||||
* and child processes.
|
||||
* @param {optional string} message
|
||||
* If provided, shows this string as the message when remoteType values
|
||||
* do not match. If not present, it uses the default message defined
|
||||
* in the function parameters.
|
||||
*/
|
||||
function checkBrowserRemoteType(
|
||||
browser,
|
||||
expectedRemoteType,
|
||||
message = `Ensures that tab runs in the ${expectedRemoteType} content process.`
|
||||
) {
|
||||
// Check both parent and child to ensure that they have the correct remoteType.
|
||||
if (expectedRemoteType == E10SUtils.WEB_REMOTE_TYPE) {
|
||||
ok(E10SUtils.isWebRemoteType(browser.remoteType), message);
|
||||
ok(
|
||||
E10SUtils.isWebRemoteType(browser.messageManager.remoteType),
|
||||
'Parent and child process should agree on the remote type.'
|
||||
);
|
||||
} else {
|
||||
is(browser.remoteType, expectedRemoteType, message);
|
||||
is(
|
||||
browser.messageManager.remoteType,
|
||||
expectedRemoteType,
|
||||
'Parent and child process should agree on the remote type.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function test_url_for_process_types({
|
||||
url,
|
||||
chromeResult,
|
||||
webContentResult,
|
||||
privilegedAboutContentResult,
|
||||
privilegedMozillaContentResult,
|
||||
extensionProcessResult,
|
||||
}) {
|
||||
const CHROME_PROCESS = E10SUtils.NOT_REMOTE;
|
||||
const WEB_CONTENT_PROCESS = E10SUtils.WEB_REMOTE_TYPE;
|
||||
const PRIVILEGEDABOUT_CONTENT_PROCESS = E10SUtils.PRIVILEGEDABOUT_REMOTE_TYPE;
|
||||
const PRIVILEGEDMOZILLA_CONTENT_PROCESS = E10SUtils.PRIVILEGEDMOZILLA_REMOTE_TYPE;
|
||||
const EXTENSION_PROCESS = E10SUtils.EXTENSION_REMOTE_TYPE;
|
||||
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(url, /* fission */ false, CHROME_PROCESS),
|
||||
chromeResult,
|
||||
'Check URL in chrome process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(url, /* fission */ false, WEB_CONTENT_PROCESS),
|
||||
webContentResult,
|
||||
'Check URL in web content process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(url, /* fission */ false, PRIVILEGEDABOUT_CONTENT_PROCESS),
|
||||
privilegedAboutContentResult,
|
||||
'Check URL in privileged about content process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(url, /* fission */ false, PRIVILEGEDMOZILLA_CONTENT_PROCESS),
|
||||
privilegedMozillaContentResult,
|
||||
'Check URL in privileged mozilla content process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(url, /* fission */ false, EXTENSION_PROCESS),
|
||||
extensionProcessResult,
|
||||
'Check URL in extension process.'
|
||||
);
|
||||
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(url + '#foo', /* fission */ false, CHROME_PROCESS),
|
||||
chromeResult,
|
||||
'Check URL with ref in chrome process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(url + '#foo', /* fission */ false, WEB_CONTENT_PROCESS),
|
||||
webContentResult,
|
||||
'Check URL with ref in web content process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(
|
||||
url + '#foo',
|
||||
/* fission */ false,
|
||||
PRIVILEGEDABOUT_CONTENT_PROCESS
|
||||
),
|
||||
privilegedAboutContentResult,
|
||||
'Check URL with ref in privileged about content process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(
|
||||
url + '#foo',
|
||||
/* fission */ false,
|
||||
PRIVILEGEDMOZILLA_CONTENT_PROCESS
|
||||
),
|
||||
privilegedMozillaContentResult,
|
||||
'Check URL with ref in privileged mozilla content process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(url + '#foo', /* fission */ false, EXTENSION_PROCESS),
|
||||
extensionProcessResult,
|
||||
'Check URL with ref in extension process.'
|
||||
);
|
||||
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(url + '?foo', /* fission */ false, CHROME_PROCESS),
|
||||
chromeResult,
|
||||
'Check URL with query in chrome process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(url + '?foo', /* fission */ false, WEB_CONTENT_PROCESS),
|
||||
webContentResult,
|
||||
'Check URL with query in web content process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(
|
||||
url + '?foo',
|
||||
/* fission */ false,
|
||||
PRIVILEGEDABOUT_CONTENT_PROCESS
|
||||
),
|
||||
privilegedAboutContentResult,
|
||||
'Check URL with query in privileged about content process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(
|
||||
url + '?foo',
|
||||
/* fission */ false,
|
||||
PRIVILEGEDMOZILLA_CONTENT_PROCESS
|
||||
),
|
||||
privilegedMozillaContentResult,
|
||||
'Check URL with query in privileged mozilla content process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(url + '?foo', /* fission */ false, EXTENSION_PROCESS),
|
||||
extensionProcessResult,
|
||||
'Check URL with query in extension process.'
|
||||
);
|
||||
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(url + '?foo#bar', /* fission */ false, CHROME_PROCESS),
|
||||
chromeResult,
|
||||
'Check URL with query and ref in chrome process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(url + '?foo#bar', /* fission */ false, WEB_CONTENT_PROCESS),
|
||||
webContentResult,
|
||||
'Check URL with query and ref in web content process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(
|
||||
url + '?foo#bar',
|
||||
/* fission */ false,
|
||||
PRIVILEGEDABOUT_CONTENT_PROCESS
|
||||
),
|
||||
privilegedAboutContentResult,
|
||||
'Check URL with query and ref in privileged about content process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(
|
||||
url + '?foo#bar',
|
||||
/* fission */ false,
|
||||
PRIVILEGEDMOZILLA_CONTENT_PROCESS
|
||||
),
|
||||
privilegedMozillaContentResult,
|
||||
'Check URL with query and ref in privileged mozilla content process.'
|
||||
);
|
||||
is(
|
||||
E10SUtils.canLoadURIInRemoteType(url + '?foo#bar', /* fission */ false, EXTENSION_PROCESS),
|
||||
extensionProcessResult,
|
||||
'Check URL with query and ref in extension process.'
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a file URL for the local file name.
|
||||
*/
|
||||
function fileURL(filename) {
|
||||
let ifile = getChromeDir(getResolvedURI(gTestPath));
|
||||
ifile.append(filename);
|
||||
return Services.io.newFileURI(ifile).spec;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a http URL for the local file name.
|
||||
*/
|
||||
function httpURL(filename, host = 'https://example.com/') {
|
||||
let root = getRootDirectory(gTestPath).replace('chrome://mochitests/content/', host);
|
||||
return root + filename;
|
||||
}
|
||||
|
||||
function loadTestSubscript(filePath) {
|
||||
Services.scriptloader.loadSubScript(new URL(filePath, gTestPath).href, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a tab group (along with its tabs). Resolves when the tab group
|
||||
* is gone.
|
||||
*
|
||||
* @param {MozTabbrowserTabGroup} group
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function removeTabGroup(group) {
|
||||
return TabGroupTestUtils.removeTabGroup(group);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} triggerNode
|
||||
* @param {string} contextMenuId
|
||||
* @returns {Promise<XULMenuElement|XULPopupElement>}
|
||||
*/
|
||||
async function getContextMenu(triggerNode, contextMenuId) {
|
||||
let win = triggerNode.ownerGlobal;
|
||||
triggerNode.scrollIntoView({ behavior: 'instant' });
|
||||
const contextMenu = win.document.getElementById(contextMenuId);
|
||||
const contextMenuShown = BrowserTestUtils.waitForPopupEvent(contextMenu, 'shown');
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(triggerNode, { type: 'contextmenu', button: 2 }, win);
|
||||
await contextMenuShown;
|
||||
return contextMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {XULMenuElement|XULPopupElement} contextMenu
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function closeContextMenu(contextMenu) {
|
||||
let menuHidden = BrowserTestUtils.waitForPopupEvent(contextMenu, 'hidden');
|
||||
contextMenu.hidePopup();
|
||||
await menuHidden;
|
||||
}
|
Reference in New Issue
Block a user