зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1686194 - Fire pagetitlechanged when initialized with an empty string r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D102054
This commit is contained in:
Родитель
f9ad45c76b
Коммит
f3d0bd2669
|
@ -364,11 +364,11 @@ IPCResult WindowGlobalParent::RecvUpdateDocumentPrincipal(
|
|||
}
|
||||
mozilla::ipc::IPCResult WindowGlobalParent::RecvUpdateDocumentTitle(
|
||||
const nsString& aTitle) {
|
||||
if (mDocumentTitle == aTitle) {
|
||||
if (mDocumentTitle.isSome() && mDocumentTitle.value() == aTitle) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mDocumentTitle = aTitle;
|
||||
mDocumentTitle = Some(aTitle);
|
||||
|
||||
// Send a pagetitlechanged event only for changes to the title
|
||||
// for top-level frames.
|
||||
|
|
|
@ -119,7 +119,9 @@ class WindowGlobalParent final : public WindowContext,
|
|||
// The current URI which loaded in the document.
|
||||
nsIURI* GetDocumentURI() override { return mDocumentURI; }
|
||||
|
||||
void GetDocumentTitle(nsAString& aTitle) const { aTitle = mDocumentTitle; }
|
||||
void GetDocumentTitle(nsAString& aTitle) const {
|
||||
aTitle = mDocumentTitle.valueOr(nsString());
|
||||
}
|
||||
|
||||
nsIPrincipal* GetContentBlockingAllowListPrincipal() const {
|
||||
return mDocContentBlockingAllowListPrincipal;
|
||||
|
@ -284,7 +286,7 @@ class WindowGlobalParent final : public WindowContext,
|
|||
// The principal to use for the content blocking allow list.
|
||||
nsCOMPtr<nsIPrincipal> mDocContentBlockingAllowListPrincipal;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
nsString mDocumentTitle;
|
||||
Maybe<nsString> mDocumentTitle;
|
||||
|
||||
bool mIsInitialDocument;
|
||||
|
||||
|
|
|
@ -20,3 +20,5 @@ skip-if = !e10s
|
|||
[browser_bug1646088.js]
|
||||
support-files = file_dummy.html
|
||||
skip-if = !e10s
|
||||
[browser_bug1686194.js]
|
||||
support-files = file_dummy.html
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
let TEST_PAGE = "http://mochi.test:8888/browser/dom/ipc/tests/file_dummy.html";
|
||||
|
||||
function untilPageTitleChanged() {
|
||||
return new Promise(resolve =>
|
||||
gBrowser.addEventListener("pagetitlechanged", resolve)
|
||||
);
|
||||
}
|
||||
|
||||
add_task(async () => {
|
||||
const tab = await BrowserTestUtils.openNewForegroundTab({
|
||||
gBrowser,
|
||||
opening: TEST_PAGE,
|
||||
});
|
||||
|
||||
const { linkedBrowser } = tab;
|
||||
ok(
|
||||
tab.getAttribute("label").includes("file_dummy.html"),
|
||||
"The title should be the raw path"
|
||||
);
|
||||
|
||||
await SpecialPowers.spawn(linkedBrowser, [], function() {
|
||||
content.document.title = "Title";
|
||||
});
|
||||
|
||||
is(tab.getAttribute("label"), "Title", "The title should change");
|
||||
|
||||
linkedBrowser.reload();
|
||||
|
||||
await untilPageTitleChanged();
|
||||
|
||||
ok(
|
||||
tab.getAttribute("label").includes("file_dummy.html"),
|
||||
"The title should be the raw path again"
|
||||
);
|
||||
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
Загрузка…
Ссылка в новой задаче