From ea34f56947044119c20bbff14ece8adf4d82d82a Mon Sep 17 00:00:00 2001 From: Arthur Iakab Date: Tue, 29 Oct 2019 03:12:18 +0200 Subject: [PATCH] Backed out changeset 8c2f5b82f33a (bug 1573753) for causing browser chrome perma failure. CLOSED TREE --- browser/components/urlbar/UrlbarInput.jsm | 27 ++++++++---- .../urlbar/tests/browser/browser.ini | 3 -- .../browser_urlbar_copy_during_load.js | 42 ------------------- .../urlbar/tests/browser/slow-page.sjs | 14 +++---- 4 files changed, 24 insertions(+), 62 deletions(-) delete mode 100644 browser/components/urlbar/tests/browser/browser_urlbar_copy_during_load.js diff --git a/browser/components/urlbar/UrlbarInput.jsm b/browser/components/urlbar/UrlbarInput.jsm index 043deee1430d..8c8639dc1daa 100644 --- a/browser/components/urlbar/UrlbarInput.jsm +++ b/browser/components/urlbar/UrlbarInput.jsm @@ -1232,18 +1232,29 @@ class UrlbarInput { if (this.getAttribute("pageproxystate") == "valid") { uri = this.window.gBrowser.currentURI; } else { - // The value could be: - // 1. a trimmed url, set by selecting a result - // 2. a search string set by selecting a result - // 3. a url that was confirmed but didn't finish loading yet - // If it's an url the untrimmedValue should resolve to a valid URI, - // otherwise it's a search string that should be copied as-is. + // We're dealing with an autocompleted value. + if (!this._resultForCurrentValue) { + throw new Error( + "UrlbarInput: Should have a UrlbarResult since " + + "pageproxystate != 'valid' and valueIsTyped == false" + ); + } + let resultURL = this._resultForCurrentValue.payload.url; + if (!resultURL) { + return selectedVal; + } + try { - uri = Services.io.newURI(this._untrimmedValue); - } catch (ex) { + uri = Services.uriFixup.createFixupURI( + resultURL, + Services.uriFixup.FIXUP_FLAG_NONE + ); + } catch (e) {} + if (!uri) { return selectedVal; } } + uri = this.makeURIReadable(uri); // If the entire URL is selected, just use the actual loaded URI, diff --git a/browser/components/urlbar/tests/browser/browser.ini b/browser/components/urlbar/tests/browser/browser.ini index 69b8f1755908..5ab804425a73 100644 --- a/browser/components/urlbar/tests/browser/browser.ini +++ b/browser/components/urlbar/tests/browser/browser.ini @@ -118,9 +118,6 @@ support-files = file_blank_but_not_blank.html [browser_urlbar_collapseOnChromeMousedown.js] [browser_urlbar_content_opener.js] -[browser_urlbar_copy_during_load.js] -support-files = - slow-page.sjs [browser_urlbar_display_selectedAction_Extensions.js] [browser_urlbar_empty_search.js] [browser_urlbar_event_telemetry.js] diff --git a/browser/components/urlbar/tests/browser/browser_urlbar_copy_during_load.js b/browser/components/urlbar/tests/browser/browser_urlbar_copy_during_load.js deleted file mode 100644 index 86ae2e47850b..000000000000 --- a/browser/components/urlbar/tests/browser/browser_urlbar_copy_during_load.js +++ /dev/null @@ -1,42 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -// Test that copying from the urlbar page works correctly after a result is -// confirmed but takes a while to load. - -add_task(async function() { - const SLOW_PAGE = - getRootDirectory(gTestPath).replace( - "chrome://mochitests/content", - "http://www.example.com" - ) + "slow-page.sjs"; - - await BrowserTestUtils.withNewTab(gBrowser, async tab => { - gURLBar.focus(); - gURLBar.value = SLOW_PAGE; - let promise = TestUtils.waitForCondition( - () => gURLBar.getAttribute("pageproxystate") == "invalid" - ); - EventUtils.synthesizeKey("KEY_Enter"); - info("wait for the initial conditions"); - await promise; - - info("Copy the whole url"); - await SimpleTest.promiseClipboardChange(SLOW_PAGE, () => { - gURLBar.select(); - goDoCommand("cmd_copy"); - }); - - info("Copy the initial part of the url, as a different valid url"); - await SimpleTest.promiseClipboardChange( - SLOW_PAGE.substring(0, SLOW_PAGE.indexOf("slow-page.sjs")), - () => { - gURLBar.selectionStart = 0; - gURLBar.selectionEnd = gURLBar.value.indexOf("slow-page.sjs"); - goDoCommand("cmd_copy"); - } - ); - }); -}); diff --git a/browser/components/urlbar/tests/browser/slow-page.sjs b/browser/components/urlbar/tests/browser/slow-page.sjs index ce9a7597445a..2612de834550 100644 --- a/browser/components/urlbar/tests/browser/slow-page.sjs +++ b/browser/components/urlbar/tests/browser/slow-page.sjs @@ -11,13 +11,9 @@ function handleRequest(request, response) { } response.processAsync(); timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); - timer.init( - () => { - response.setHeader("Content-Type", "text/html", false); - response.write("This is a slow loading page."); - response.finish(); - }, - DELAY_MS, - Ci.nsITimer.TYPE_ONE_SHOT - ); + timer.init(() => { + response.setHeader("Content-Type", "text/html", false); + response.write("This was the slow load. You should never see this."); + response.finish(); + }, DELAY_MS, Ci.nsITimer.TYPE_ONE_SHOT); }