4 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
5 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css" />
9 <script type=
"text/javascript">
10 // XXX(nika): Why are we using SpecialPowers here? If we're a chrome mochitest
11 // can't we avoid using the SpecialPowers wrappers?
12 const Cc
= SpecialPowers
.Cc
;
13 const Ci
= SpecialPowers
.Ci
;
14 const Cu
= SpecialPowers
.Cu
;
16 const { ComponentUtils
} = ChromeUtils
.importESModule(
17 "resource://gre/modules/ComponentUtils.sys.mjs"
20 const HELPERAPP_DIALOG_CID
=
21 SpecialPowers
.wrap(SpecialPowers
.Components
)
22 .ID(Cc
["@mozilla.org/helperapplauncherdialog;1"].number
);
23 const HELPERAPP_DIALOG_CONTRACT_ID
= "@mozilla.org/helperapplauncherdialog;1";
24 const MOCK_HELPERAPP_DIALOG_CID
=
25 SpecialPowers
.wrap(SpecialPowers
.Components
)
26 .ID("{391832c8-5232-4676-b838-cc8ad373f3d8}");
28 var registrar
= SpecialPowers
.wrap(Components
).manager
29 .QueryInterface(Ci
.nsIComponentRegistrar
);
31 const HandlerService
= Cc
[
32 "@mozilla.org/uriloader/handler-service;1"
33 ].getService(Ci
.nsIHandlerService
);
35 const MIMEService
= Cc
["@mozilla.org/mime;1"].getService(Ci
.nsIMIMEService
);
37 var helperAppDlgPromise
= new Promise(function(resolve
) {
38 var mockHelperAppService
;
40 function HelperAppLauncherDialog() {
43 HelperAppLauncherDialog
.prototype = {
44 show(aLauncher
, aWindowContext
, aReason
) {
45 ok(true, "Whether showing Dialog");
47 registrar
.unregisterFactory(MOCK_HELPERAPP_DIALOG_CID
,
48 mockHelperAppService
);
50 QueryInterface
: ChromeUtils
.generateQI(["nsIHelperAppLauncherDialog"]),
53 mockHelperAppService
= ComponentUtils
.generateSingletonFactory(HelperAppLauncherDialog
);
54 registrar
.registerFactory(MOCK_HELPERAPP_DIALOG_CID
, "",
55 HELPERAPP_DIALOG_CONTRACT_ID
,
56 mockHelperAppService
);
59 add_task(async
function() {
60 // ensure the download triggers the external app dialog
61 const mimeInfo
= MIMEService
.getFromTypeAndExtension("application/octet-stream", "");
62 mimeInfo
.alwaysAskBeforeHandling
= true;
63 HandlerService
.store(mimeInfo
);
65 SimpleTest
.registerCleanupFunction(() => {
66 HandlerService
.remove(mimeInfo
);
69 let promise
= new Promise(function(resolve
) {
70 let iframe
= document
.createElement("iframe");
71 iframe
.onload = function() {
72 is(iframe
.contentDocument
.getElementById("edit").innerText
, "abc",
73 "load iframe source");
76 iframe
.id
= "testframe";
77 iframe
.src
= "data:text/html,<div id=edit contenteditable=true>abc</div>";
78 document
.body
.appendChild(iframe
);
83 let iframe
= document
.getElementById("testframe");
84 let docShell
= SpecialPowers
.wrap(iframe
.contentWindow
).docShell
;
86 ok(docShell
.hasEditingSession
, "Should have editing session");
88 document
.getElementById("testframe").src
=
89 "data:application/octet-stream,TESTCONTENT";
91 await helperAppDlgPromise
;
93 ok(docShell
.hasEditingSession
, "Should have editing session");