4 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
5 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
9 <div id=
"edit" contenteditable
></div>
12 const Cc
= SpecialPowers
.Cc
;
13 const Ci
= SpecialPowers
.Ci
;
15 function getHTMLEditor(aWindow
) {
16 let editingSession
= SpecialPowers
.wrap(aWindow
).docShell
.editingSession
;
17 if (!editingSession
) {
20 let editor
= editingSession
.getEditorForWindow(aWindow
);
24 return editor
.QueryInterface(Ci
.nsIHTMLEditor
);
29 mimeType
: "image/gif",
30 base64
: "R0lGODdhAQACAPABAAD/AP///ywAAAAAAQACAAACAkQKADs="
33 mimeType
: "image/jpeg",
34 base64
: "/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wgALCAABAAEBAREA/8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABPxA="
37 mimeType
: "image/png",
38 base64
: "iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAIAAABvrngfAAAAFklEQVQImWMwjWhCQwxECoW3oCHihAB0LyYv5/oAHwAAAABJRU5ErkJggg=="
42 add_task(async
function() {
43 await
new Promise(resolve
=> SimpleTest
.waitForFocus(resolve
, window
));
45 let edit
= document
.getElementById("edit");
48 await
new Promise(resolve
=> SimpleTest
.executeSoon(resolve
));
50 for (const test
of TESTS
) {
51 let bin
= window
.atob(test
.base64
);
52 let stringStream
= Cc
["@mozilla.org/io/string-input-stream;1"].createInstance(
53 Ci
.nsIStringInputStream
55 stringStream
.setData(bin
, bin
.length
);
57 let trans
= Cc
["@mozilla.org/widget/transferable;1"].createInstance(
61 trans
.setTransferData(test
.mimeType
, stringStream
);
63 getHTMLEditor(window
).pasteTransferable(trans
);
66 "<img src=\"data:" + test
.mimeType
+ ";base64," + test
.base64
+ "\" alt=\"\">",
67 "pastedTransferable pastes image as data URL");