Bug 952456 - Part 3: Enable test_copyimage.html on gonk/cocoa r=fabrice

Enable dom/base/test/test_copyimage.html on b2g emulators and macos
This commit is contained in:
Boris Chiou 2015-08-17 15:49:30 -07:00
parent 82bc89b6d6
commit f62467fb22
2 changed files with 50 additions and 21 deletions

View File

@ -698,7 +698,7 @@ support-files = referrerHelper.js
[test_classList.html]
# This test fails on the Mac for some reason
[test_copyimage.html]
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') || toolkit != 'gtk2' && toolkit != 'gtk3' && toolkit != 'windows' || e10s #b2g-desktop(Bug 931116, b2g desktop specific, initial triage)
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') || (toolkit != 'cocoa' && toolkit != 'gonk' && toolkit != 'gtk2' && toolkit != 'gtk3' && toolkit != 'windows') || e10s #b2g-desktop(Bug 931116, b2g desktop specific, initial triage)
[test_copypaste.html]
skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #bug 904183 # b2g(clipboard undefined) b2g-debug(clipboard undefined) b2g-desktop(clipboard undefined)
[test_copypaste.xhtml]

View File

@ -1,6 +1,8 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=518249
https://bugzilla.mozilla.org/show_bug.cgi?id=952456
-->
<head>
<title>Test for copy image</title>
@ -9,6 +11,7 @@
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=518249">Mozilla Bug 518249</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=952456">Mozilla Bug 952456</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
@ -16,38 +19,64 @@
<script class="testbody" type="text/javascript">
function testCopyImage () {
// selection of the node
var Ci = SpecialPowers.Ci;
var Cc = SpecialPowers.Cc;
var clipboard = SpecialPowers.Services.clipboard;
function getClipboardData(mime) {
var transferable = Cc['@mozilla.org/widget/transferable;1']
.createInstance(Ci.nsITransferable);
var loadingContext = SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsILoadContext);
transferable.init(loadingContext);
transferable.addDataFlavor(mime);
clipboard.getData(transferable, 1);
var data = SpecialPowers.createBlankObject();
transferable.getTransferData(mime, data, {});
return data;
}
function testClipboardValue(mime, expected) {
var data = SpecialPowers.wrap(getClipboardData(mime));
var str = data.value == null ? data.value :
data.value.QueryInterface(Ci.nsISupportsString).data;
is(str, expected, "clipboard has correct [" + mime + "] content")
}
//--------- Prepare data and copy it.
// Select the node.
var node = document.getElementById('logo');
// Set node and copy image.
var webnav = SpecialPowers.wrap(window)
.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
.getInterface(SpecialPowers.Ci.nsIWebNavigation)
var docShell = webnav.QueryInterface(SpecialPowers.Ci.nsIDocShell);
docShell.chromeEventHandler.ownerDocument.popupNode = node;
// let's copy the node
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
var docShell = webnav.QueryInterface(Ci.nsIDocShell);
var documentViewer = docShell.contentViewer
.QueryInterface(SpecialPowers.Ci.nsIContentViewerEdit);
.QueryInterface(Ci.nsIContentViewerEdit);
documentViewer.setCommandNode(node);
documentViewer.copyImage(documentViewer.COPY_IMAGE_ALL);
//--------- now check the content of the clipboard
var clipboard = SpecialPowers.Cc["@mozilla.org/widget/clipboard;1"]
.getService(SpecialPowers.Ci.nsIClipboard);
// does the clipboard contain text/unicode data ?
//--------- Let's check the content of the clipboard now.
// Does the clipboard contain text/unicode data ?
ok(clipboard.hasDataMatchingFlavors(["text/unicode"], 1, clipboard.kGlobalClipboard), "clipboard contains unicode text");
// does the clipboard contain text/html data ?
// Does the clipboard contain text/html data ?
ok(clipboard.hasDataMatchingFlavors(["text/html"], 1, clipboard.kGlobalClipboard), "clipboard contains html text");
// does the clipboard contain image data ?
// Does the clipboard contain image data ?
ok(clipboard.hasDataMatchingFlavors(["image/png"], 1, clipboard.kGlobalClipboard), "clipboard contains image");
// Is the text/uncodie data correct ?
testClipboardValue('text/unicode', 'about:logo');
// Is the text/html data correct ?
testClipboardValue('text/html', '<img id="logo" src="about:logo">');
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(testCopyImage);
</script>