Open links and images in new browser tabs
- A middle-click on a link opens the link in a new tab. Scrolling starts at once, as before. The new engine command linkAt reads the link under the pointer in an isolated world. When it finds a web link, the tab stops the scroll and opens the link. - The image menu of a page starts with Open image in new tab. A new tab opens in front, like Open link in new tab. The engine smoke test checks linkAt, and the interaction test checks both actions with the real engine. Cards 333909d1 and f7ee842d.
This commit is contained in:
@@ -161,6 +161,13 @@ app.whenReady().then(async () => {
|
||||
assert.equal(whole.subarray(0, 6).toString(), 'GIF89a');
|
||||
assert.equal(whole.at(-1), 0x3b);
|
||||
await wc.executeJavaScript('document.querySelector("#copy-image").remove();true;');
|
||||
// A middle-click asks for the link under the pointer. Only web links count.
|
||||
await wc.executeJavaScript(`document.body.insertAdjacentHTML('beforeend', '<a id="middle-link" href="${process.env.RS_TEST_URL}linked" style="position:absolute;left:600px;top:40px;width:120px;height:30px;display:block">Linked</a><a id="script-link" href="javascript:void(0)" style="position:absolute;left:600px;top:100px;width:120px;height:30px;display:block">Script</a>');true;`);
|
||||
assert.deepEqual(await engine.command('linkAt', { tabId: first, x: 650, y: 50 }), { url: `${process.env.RS_TEST_URL}linked` });
|
||||
assert.deepEqual(await engine.command('linkAt', { tabId: first, x: 650, y: 110 }), { url: null });
|
||||
assert.deepEqual(await engine.command('linkAt', { tabId: first, x: 900, y: 600 }), { url: null });
|
||||
await assert.rejects(engine.command('linkAt', { tabId: first, x: -1, y: 50 }), /Invalid pointer position/);
|
||||
await wc.executeJavaScript('document.querySelector("#middle-link").remove(); document.querySelector("#script-link").remove();true;');
|
||||
// An image that opens as the page itself is the main resource of the tab.
|
||||
const direct = (await engine.command('newTab', { url: `${process.env.RS_TEST_URL}direct.gif` })).tabId;
|
||||
const directContents = engine.tabs.get(direct).view.webContents;
|
||||
@@ -174,6 +181,7 @@ app.whenReady().then(async () => {
|
||||
assert.deepEqual([directCopy.mime, directCopy.size], ['image/gif', large.size]);
|
||||
await engine.command('closeTab', { tabId: direct });
|
||||
passed.push('Copy image keeps the loaded GIF bytes without a second request, also for an image that opens as the page');
|
||||
passed.push('A middle-click finds the web link under the pointer');
|
||||
await until(async () => await wc.executeJavaScript("getComputedStyle(document.querySelector('.advertisement')).display") === 'none');
|
||||
assert.equal(await wc.executeJavaScript('typeof window.adExecuted'), 'undefined');
|
||||
passed.push('network and cosmetic ad blocking remain active');
|
||||
|
||||
Reference in New Issue
Block a user