summaryrefslogtreecommitdiffstats
path: root/application/palemoon/base/content/urlbarBindings.xml
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-15 09:46:17 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-15 09:46:17 +0200
commitf2b4134845cb61831847e6746de2f15051d65a08 (patch)
tree06516a6ea2a72b44edec1a5b74ae3e4e4369be48 /application/palemoon/base/content/urlbarBindings.xml
parent0c6c32a0e6243040360d9dce05af377e95a71a5f (diff)
downloadUXP-f2b4134845cb61831847e6746de2f15051d65a08.tar
UXP-f2b4134845cb61831847e6746de2f15051d65a08.tar.gz
UXP-f2b4134845cb61831847e6746de2f15051d65a08.tar.lz
UXP-f2b4134845cb61831847e6746de2f15051d65a08.tar.xz
UXP-f2b4134845cb61831847e6746de2f15051d65a08.zip
Bug 989984 - getShortcutOrURIAndPostData should have a synchronous callback behavior
Issue #112
Diffstat (limited to 'application/palemoon/base/content/urlbarBindings.xml')
-rw-r--r--application/palemoon/base/content/urlbarBindings.xml147
1 files changed, 77 insertions, 70 deletions
diff --git a/application/palemoon/base/content/urlbarBindings.xml b/application/palemoon/base/content/urlbarBindings.xml
index e0bb40d64..44b398304 100644
--- a/application/palemoon/base/content/urlbarBindings.xml
+++ b/application/palemoon/base/content/urlbarBindings.xml
@@ -264,29 +264,35 @@
var action = this._parseActionUrl(url);
let lastLocationChange = gBrowser.selectedBrowser.lastLocationChange;
- Task.spawn(function() {
- let matchLastLocationChange = true;
- if (action) {
- url = action.param;
- if (this.hasAttribute("actiontype")) {
- if (action.type == "switchtab") {
- this.handleRevert();
- let prevTab = gBrowser.selectedTab;
- if (switchToTabHavingURI(url) &&
- isTabEmpty(prevTab))
- gBrowser.removeTab(prevTab);
- }
- return;
+
+ let matchLastLocationChange = true;
+ if (action) {
+ url = action.param;
+ if (this.hasAttribute("actiontype")) {
+ if (action.type == "switchtab") {
+ this.handleRevert();
+ let prevTab = gBrowser.selectedTab;
+ if (switchToTabHavingURI(url) &&
+ isTabEmpty(prevTab))
+ gBrowser.removeTab(prevTab);
}
+ return;
}
- else {
- [url, postData, mayInheritPrincipal] = yield this._canonizeURL(aTriggeringEvent);
- matchLastLocationChange = (lastLocationChange ==
- gBrowser.selectedBrowser.lastLocationChange);
- if (!url)
- return;
- }
+ continueOperation.call(this);
+ }
+ else {
+ this._canonizeURL(aTriggeringEvent, response => {
+ [url, postData, mayInheritPrincipal] = response;
+ if (url) {
+ matchLastLocationChange = (lastLocationChange ==
+ gBrowser.selectedBrowser.lastLocationChange);
+ continueOperation.call(this);
+ }
+ });
+ }
+ function continueOperation()
+ {
this.value = url;
gBrowser.userTypedValue = url;
try {
@@ -355,73 +361,74 @@
loadCurrent();
}
}
- }.bind(this));
+ }
]]></body>
</method>
<method name="_canonizeURL">
<parameter name="aTriggeringEvent"/>
+ <parameter name="aCallback"/>
<body><![CDATA[
- return Task.spawn(function() {
- var url = this.value;
- if (!url)
- throw new Task.Result(["", null, false]);
-
- // Only add the suffix when the URL bar value isn't already "URL-like",
- // and only if we get a keyboard event, to match user expectations.
- if (/^\s*[^.:\/\s]+(?:\/.*|\s*)$/i.test(url) &&
- (aTriggeringEvent instanceof KeyEvent)) {
+ var url = this.value;
+ if (!url) {
+ aCallback(["", null, false]);
+ return;
+ }
+
+ // Only add the suffix when the URL bar value isn't already "URL-like",
+ // and only if we get a keyboard event, to match user expectations.
+ if (/^\s*[^.:\/\s]+(?:\/.*|\s*)$/i.test(url) &&
+ (aTriggeringEvent instanceof KeyEvent)) {
#ifdef XP_MACOSX
- let accel = aTriggeringEvent.metaKey;
+ let accel = aTriggeringEvent.metaKey;
#else
- let accel = aTriggeringEvent.ctrlKey;
+ let accel = aTriggeringEvent.ctrlKey;
#endif
- let shift = aTriggeringEvent.shiftKey;
-
- let suffix = "";
-
- switch (true) {
- case (accel && shift):
- suffix = ".org/";
- break;
- case (shift):
- suffix = ".net/";
- break;
- case (accel):
- try {
- suffix = gPrefService.getCharPref("browser.fixup.alternate.suffix");
- if (suffix.charAt(suffix.length - 1) != "/")
- suffix += "/";
- } catch(e) {
- suffix = ".com/";
- }
- break;
- }
+ let shift = aTriggeringEvent.shiftKey;
- if (suffix) {
- // trim leading/trailing spaces (bug 233205)
- url = url.trim();
+ let suffix = "";
+
+ switch (true) {
+ case (accel && shift):
+ suffix = ".org/";
+ break;
+ case (shift):
+ suffix = ".net/";
+ break;
+ case (accel):
+ try {
+ suffix = gPrefService.getCharPref("browser.fixup.alternate.suffix");
+ if (suffix.charAt(suffix.length - 1) != "/")
+ suffix += "/";
+ } catch(e) {
+ suffix = ".com/";
+ }
+ break;
+ }
- // Tack www. and suffix on. If user has appended directories, insert
- // suffix before them (bug 279035). Be careful not to get two slashes.
+ if (suffix) {
+ // trim leading/trailing spaces (bug 233205)
+ url = url.trim();
- let firstSlash = url.indexOf("/");
+ // Tack www. and suffix on. If user has appended directories, insert
+ // suffix before them (bug 279035). Be careful not to get two slashes.
- if (firstSlash >= 0) {
- url = url.substring(0, firstSlash) + suffix +
- url.substring(firstSlash + 1);
- } else {
- url = url + suffix;
- }
+ let firstSlash = url.indexOf("/");
- url = "http://www." + url;
+ if (firstSlash >= 0) {
+ url = url.substring(0, firstSlash) + suffix +
+ url.substring(firstSlash + 1);
+ } else {
+ url = url + suffix;
}
- }
- let data = yield getShortcutOrURIAndPostData(url);
+ url = "http://www." + url;
+ }
+ }
- throw new Task.Result([data.url, data.postData, data.mayInheritPrincipal]);
- }.bind(this));
+ getShortcutOrURIAndPostData(url, data => {
+ aCallback([data.url, data.postData, data.mayInheritPrincipal]);
+ });
]]></body>
</method>