mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 04:58:00 +00:00
Bug 554400, convert search.xml to use new dropped link handler, r=gavin
This commit is contained in:
parent
cfa97b3d01
commit
38f28e8ac1
@ -723,29 +723,6 @@
|
||||
}
|
||||
}
|
||||
})]]></field>
|
||||
|
||||
<!-- DND Observer -->
|
||||
<field name="searchbarDNDObserver" readonly="true"><![CDATA[({
|
||||
mOuter: this,
|
||||
|
||||
onDrop: function (aEvent, aXferData, aDragSession) {
|
||||
var data = transferUtils.retrieveURLFromData(aXferData.data,
|
||||
aXferData.flavour.contentType);
|
||||
if (data) {
|
||||
this.mOuter.value = data;
|
||||
this.mOuter.onTextEntered(aEvent);
|
||||
}
|
||||
},
|
||||
|
||||
getSupportedFlavours: function () {
|
||||
var flavourSet = new FlavourSet();
|
||||
|
||||
flavourSet.appendFlavour("text/unicode");
|
||||
flavourSet.appendFlavour("text/x-moz-url");
|
||||
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
|
||||
return flavourSet;
|
||||
}
|
||||
})]]></field>
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
@ -771,8 +748,26 @@
|
||||
action="return this.openSearch();"/>
|
||||
#endif
|
||||
|
||||
<handler event="drop" phase="capturing">
|
||||
nsDragAndDrop.drop(event, this.searchbarDNDObserver);
|
||||
<handler event="dragover">
|
||||
<![CDATA[
|
||||
var types = event.dataTransfer.types;
|
||||
if (types.contains("text/plain") || types.contains("text/x-moz-text-internal"))
|
||||
event.preventDefault();
|
||||
]]>
|
||||
</handler>
|
||||
|
||||
<handler event="drop">
|
||||
<![CDATA[
|
||||
var dataTransfer = event.dataTransfer;
|
||||
var data = dataTransfer.getData("text/plain");
|
||||
if (!data)
|
||||
data = dataTransfer.getData("text/x-moz-text-internal");
|
||||
if (data) {
|
||||
event.preventDefault();
|
||||
this.value = data;
|
||||
this.onTextEntered(event);
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
|
||||
</handlers>
|
||||
|
@ -125,12 +125,44 @@ function test() {
|
||||
isnot(event.originalTarget, gBrowser.contentDocument,
|
||||
"Shift+MiddleClick loaded results in background tab");
|
||||
|
||||
testRightClick();
|
||||
testDropText();
|
||||
});
|
||||
}
|
||||
|
||||
// prevent the search buttonmenu from opening during the drag tests
|
||||
function stopPopup(event) { event.preventDefault(); }
|
||||
|
||||
function testDropText() {
|
||||
init();
|
||||
searchBar.addEventListener("popupshowing", stopPopup, true);
|
||||
// drop on the search button so that we don't need to worry about the
|
||||
// default handlers for textboxes.
|
||||
EventUtils.synthesizeDrop(searchBar.searchButton, [[ {type: "text/plain", data: "Some Text" } ]], "copy", window);
|
||||
doOnloadOnce(function(event) {
|
||||
is(searchBar.value, "Some Text", "drop text/plain on searchbar");
|
||||
testDropInternalText();
|
||||
});
|
||||
}
|
||||
|
||||
function testDropInternalText() {
|
||||
init();
|
||||
EventUtils.synthesizeDrop(searchBar.searchButton, [[ {type: "text/x-moz-text-internal", data: "More Text" } ]], "copy", window);
|
||||
doOnloadOnce(function(event) {
|
||||
is(searchBar.value, "More Text", "drop text/x-moz-text-internal on searchbar");
|
||||
testDropLink();
|
||||
});
|
||||
}
|
||||
|
||||
function testDropLink() {
|
||||
init();
|
||||
EventUtils.synthesizeDrop(searchBar.searchButton, [[ {type: "text/uri-list", data: "http://www.mozilla.org" } ]], "copy", window);
|
||||
is(searchBar.value, "More Text", "drop text/uri-list on searchbar");
|
||||
SimpleTest.executeSoon(testRightClick);
|
||||
}
|
||||
|
||||
function testRightClick() {
|
||||
init();
|
||||
searchBar.removeEventListener("popupshowing", stopPopup, true);
|
||||
content.location.href = "about:blank";
|
||||
simulateClick({ button: 2 }, searchButton);
|
||||
setTimeout(function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user