1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const frameSource = `<a href="about:mozilla">Inner frame</a>`;
const source = `<html><h1>Top level text</h1><iframe srcdoc='${frameSource}' id="f"></iframe></html>`;
add_task(async function testPrintFrame() {
let url = `data:text/html,${source}`;
await BrowserTestUtils.withNewTab({ gBrowser, url }, async function(browser) {
let contentAreaContextMenuPopup = document.getElementById(
"contentAreaContextMenu"
);
let popupShownPromise = BrowserTestUtils.waitForEvent(
contentAreaContextMenuPopup,
"popupshown"
);
await BrowserTestUtils.synthesizeMouseAtCenter(
"#f",
{ type: "contextmenu", button: 2 },
gBrowser.selectedBrowser
);
await popupShownPromise;
let frameItem = document.getElementById("frame");
let frameContextMenu = frameItem.menupopup;
popupShownPromise = BrowserTestUtils.waitForEvent(
frameContextMenu,
"popupshown"
);
frameItem.openMenu(true);
await popupShownPromise;
let popupHiddenPromise = BrowserTestUtils.waitForEvent(
frameContextMenu,
"popuphidden"
);
let item = document.getElementById("context-printframe");
frameContextMenu.activateItem(item);
await popupHiddenPromise;
let helper = new PrintHelper(browser);
await helper.waitForDialog();
let previewBrowser = helper.currentPrintPreviewBrowser;
is(
previewBrowser.getAttribute("previewtype"),
"source",
"Source preview was rendered"
);
let textContent = await SpecialPowers.spawn(
previewBrowser,
[],
() => content.document.body.textContent
);
is(textContent, "Inner frame", "Correct content loaded");
is(
helper.win.PrintEventHandler.printFrameOnly,
true,
"Print frame only is true"
);
PrintHelper.resetPrintPrefs();
});
});
|