mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 04:09:50 +00:00
Bug 668019 - prepend http:// to URL copy selection if URL has been selected (but not loaded) from location bar. r=gavin
This commit is contained in:
parent
1af6e7a560
commit
537ec1830c
@ -2509,6 +2509,7 @@ function URLBarSetURI(aURI) {
|
||||
}
|
||||
|
||||
gURLBar.value = value;
|
||||
gURLBar.valueIsTyped = !valid;
|
||||
SetPageProxyState(valid ? "valid" : "invalid");
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,7 @@ let tests = [
|
||||
expected: testURL,
|
||||
setup: function() {
|
||||
gURLBar.value = testActionURL;
|
||||
gURLBar.valueIsTyped = true;
|
||||
is(gURLBar.value, testActionURL, "gURLBar.value starts with correct value");
|
||||
|
||||
// Focus the urlbar so we can select it all & copy
|
||||
@ -103,6 +104,7 @@ let tests = [
|
||||
setup: function() {
|
||||
// Reset urlbar value
|
||||
gURLBar.value = testActionURL;
|
||||
gURLBar.valueIsTyped = true;
|
||||
// Sanity check that we have the right value
|
||||
is(gURLBar.value, testActionURL, "gURLBar.value starts with correct value");
|
||||
|
||||
|
@ -126,8 +126,10 @@ function nextTest() {
|
||||
|
||||
function runTest(test, cb) {
|
||||
function doCheck() {
|
||||
if (test.setURL || test.loadURL)
|
||||
if (test.setURL || test.loadURL) {
|
||||
gURLBar.valueIsTyped = !!test.setURL;
|
||||
is(gURLBar.value, test.expectedURL, "url bar value set");
|
||||
}
|
||||
|
||||
testCopy(test.copyVal, test.copyExpected, cb);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
function testVal(originalValue, targetValue) {
|
||||
gURLBar.value = originalValue;
|
||||
gURLBar.valueIsTyped = false;
|
||||
is(gURLBar.value, targetValue || originalValue, "url bar value set");
|
||||
}
|
||||
|
||||
@ -63,6 +64,7 @@ function test() {
|
||||
|
||||
testCopy("example.com", "http://example.com/", function () {
|
||||
SetPageProxyState("invalid");
|
||||
gURLBar.valueIsTyped = true;
|
||||
testCopy("example.com", "example.com", finish);
|
||||
});
|
||||
}, true);
|
||||
|
@ -185,6 +185,8 @@
|
||||
<method name="trimValue">
|
||||
<parameter name="aURL"/>
|
||||
<body><![CDATA[
|
||||
// This method must not modify the given URL such that calling
|
||||
// nsIURIFixup::createFixupURI with the result will produce a different URI.
|
||||
return this._mayTrimURLs ? trimURL(aURL) : aURL;
|
||||
]]></body>
|
||||
</method>
|
||||
@ -497,13 +499,21 @@
|
||||
|
||||
// If the selection doesn't start at the beginning or URL bar is
|
||||
// modified, nothing else to do here.
|
||||
if (this.getAttribute("pageproxystate") != "valid" || this.selectionStart > 0)
|
||||
if (this.selectionStart > 0 || this.valueIsTyped)
|
||||
return selectedVal;
|
||||
|
||||
let uriFixup = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup);
|
||||
|
||||
let uri;
|
||||
try {
|
||||
uri = uriFixup.createFixupURI(inputVal, Ci.nsIURIFixup.FIXUP_FLAG_NONE);
|
||||
} catch (e) {}
|
||||
if (!uri)
|
||||
return selectedVal;
|
||||
|
||||
let uri = gBrowser.currentURI;
|
||||
// Only copy exposable URIs
|
||||
try {
|
||||
uri = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup).createExposableURI(uri);
|
||||
uri = uriFixup.createExposableURI(uri);
|
||||
} catch (ex) {}
|
||||
|
||||
// If the entire URL is selected, just use the actual loaded URI.
|
||||
|
@ -265,6 +265,7 @@
|
||||
|
||||
<!-- =================== PUBLIC MEMBERS =================== -->
|
||||
|
||||
<field name="valueIsTyped">false</field>
|
||||
<property name="value">
|
||||
<getter><![CDATA[
|
||||
if (typeof this.onBeforeValueGet == "function") {
|
||||
@ -283,6 +284,7 @@
|
||||
if (typeof this.trimValue == "function")
|
||||
val = this.trimValue(val);
|
||||
|
||||
this.valueIsTyped = false;
|
||||
this.inputField.value = val;
|
||||
|
||||
if (typeof this.formatValue == "function")
|
||||
@ -559,6 +561,7 @@
|
||||
<handlers>
|
||||
<handler event="input"><![CDATA[
|
||||
if (!this.mIgnoreInput && this.mController.input == this) {
|
||||
this.valueIsTyped = true;
|
||||
this.mController.handleText(true);
|
||||
}
|
||||
this.resetActionType();
|
||||
|
Loading…
x
Reference in New Issue
Block a user