mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-12 00:50:40 +00:00
Backed out changeset ba0820e380a3 (bug 1540150) for Mochitest failures in layout/generic/test/test_bug496275.html. CLOSED TREE
This commit is contained in:
parent
c8dcbba86c
commit
652a1d165f
@ -13,58 +13,37 @@ function runTests()
|
||||
|
||||
let iframe = document.createElement('iframe');
|
||||
document.body.appendChild(iframe);
|
||||
iframe.contentDocument.body.innerHTML = '<div id="outer"/>';
|
||||
iframe.contentDocument.body.innerHTML = '<div id="outter"/>';
|
||||
|
||||
let iframeDoc = iframe.contentDocument;
|
||||
let iframeWin = iframe.contentWindow;
|
||||
|
||||
let shadow = iframeDoc.querySelector('#outer').attachShadow({mode: 'open'});
|
||||
let shadow = iframeDoc.querySelector('#outter').attachShadow({mode: 'open'});
|
||||
let target = iframeDoc.createElement('a');
|
||||
|
||||
const TEXT = "Drag me if you can!";
|
||||
let linkText = iframeDoc.createTextNode(TEXT);
|
||||
let linkText = iframeDoc.createTextNode("Drag me if you can!");
|
||||
target.appendChild(linkText);
|
||||
|
||||
const URL = "http://www.mozilla.org/";
|
||||
target.href = URL;
|
||||
target.href = "http://www.mozilla.org/";
|
||||
shadow.appendChild(target);
|
||||
|
||||
// Some of the drag data we don't actually care about for this test,
|
||||
// so we'll use this comparator function to ignore them.
|
||||
function ignoreFunc(actualData, expectedData) {
|
||||
return true;
|
||||
let dataTransfer;
|
||||
let trapDrag = function(event) {
|
||||
ok(true, "Got dragstart event");
|
||||
dataTransfer = event.dataTransfer;
|
||||
ok(dataTransfer, "DataTransfer object is available.");
|
||||
is(SpecialPowers.wrap(dataTransfer).mozItemCount, 1, "initial link item count");
|
||||
is(dataTransfer.getData("text/uri-list"), "http://www.mozilla.org/", "link text/uri-list");
|
||||
is(dataTransfer.getData("text/plain"), "http://www.mozilla.org/", "link text/plain");
|
||||
}
|
||||
|
||||
const EXPECTED_DRAG_DATA = [[{
|
||||
type: "text/x-moz-url",
|
||||
data: "",
|
||||
eqTest: ignoreFunc,
|
||||
}, {
|
||||
type: "text/x-moz-url-data",
|
||||
data: "",
|
||||
eqTest: ignoreFunc,
|
||||
}, {
|
||||
type: "text/x-moz-url-desc",
|
||||
data: "",
|
||||
eqTest: ignoreFunc,
|
||||
}, {
|
||||
type: "text/uri-list",
|
||||
data: URL,
|
||||
}, {
|
||||
type: "text/_moz_htmlinfo",
|
||||
data: "",
|
||||
eqTest: ignoreFunc,
|
||||
}, {
|
||||
type: "text/html",
|
||||
data: "",
|
||||
eqTest: ignoreFunc,
|
||||
}, {
|
||||
type: "text/plain",
|
||||
data: URL,
|
||||
}]];
|
||||
|
||||
let result = synthesizeDragStart(target, EXPECTED_DRAG_DATA, iframeWin);
|
||||
is(result, null, "Should have gotten the expected drag data.");
|
||||
ok(!dragService.getCurrentSession(), "There shouldn't be a drag session!");
|
||||
iframeWin.addEventListener("dragstart", trapDrag, true);
|
||||
synthesizeMouse(target, 2, 2, { type: "mousedown" }, iframeWin);
|
||||
synthesizeMouse(target, 11, 11, { type: "mousemove" }, iframeWin);
|
||||
synthesizeMouse(target, 20, 20, { type: "mousemove" }, iframeWin);
|
||||
iframeWin.removeEventListener("dragstart", trapDrag, true);
|
||||
ok(dragService.getCurrentSession(), "Drag session is available.");
|
||||
dragService.endDragSession(false);
|
||||
ok(!dragService.getCurrentSession(), "There shouldn't be a drag session anymore!");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
@ -26,11 +26,6 @@ function doShiftDrag(){
|
||||
// Drag canvas element starts with a mouse down event, combine with shift
|
||||
// key, follows by two mouse move events.
|
||||
|
||||
canvas.addEventListener("dragstart", e => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
// Press on left-top corner of the canvas element.
|
||||
wu.sendMouseEvent('mousedown', canvasRect.left, canvasRect.top, 0, 1, 4);
|
||||
// Move to the center of this cavas element.
|
||||
|
@ -205,23 +205,6 @@ nsBaseDragService::InvokeDragSession(
|
||||
nsContentPolicyType aContentPolicyType = nsIContentPolicy::TYPE_OTHER) {
|
||||
AUTO_PROFILER_LABEL("nsBaseDragService::InvokeDragSession", OTHER);
|
||||
|
||||
// If you're hitting this, a test is causing the browser to attempt to enter
|
||||
// the drag-drop native nested event loop, which will put the browser in a
|
||||
// state that won't run tests properly until there's manual intervention
|
||||
// to exit the drag-drop loop (either by moving the mouse or hitting escape),
|
||||
// which can't be done from script since we're in the nested loop.
|
||||
//
|
||||
// The best way to avoid this is to catch the dragstart event on the item
|
||||
// being dragged, and then to call preventDefault() and stopPropagating() on
|
||||
// it. Alternatively, use EventUtils.synthesizeDragStart, which will do this
|
||||
// for you.
|
||||
if (XRE_IsParentProcess()) {
|
||||
MOZ_ASSERT(
|
||||
!xpc::IsInAutomation(),
|
||||
"About to start drag-drop native loop on which will prevent later "
|
||||
"tests from running properly.");
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(aDOMNode, NS_ERROR_INVALID_ARG);
|
||||
NS_ENSURE_TRUE(mSuppressLevel == 0, NS_ERROR_FAILURE);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user