Closed Bug 1686194 Opened 4 years ago Closed 4 years ago

Firefox show title of former document if new document has no title.

Categories

(Core :: DOM: Core & HTML, defect)

Firefox 84
defect

Tracking

()

RESOLVED FIXED
87 Branch
Tracking Status
firefox87 --- fixed

People

(Reporter: erwinmoller, Assigned: saschanaz)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0

Steps to reproduce:

I found this issue during development of a website.

  1. Created a page with a hyperlink to a non-existent document.
  2. Loaded that page in Firefox
  3. Clicked on the link
    --> I got the (expected) not-found page of my webserver (IIS in this case)
  4. Create the document with that name WITHOUT a title.
  5. Reload in firefox

Actual results:

The title of the former document was still displayed.

Expected results:

An empty title

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core

Somehow couldn't reproduce it with the steps in the comment #0, but got another set of steps:

  1. Load an existing HTML file on the local server, with its content <title>Title</title>
  2. Remove Title from the title element
  3. Reload

Expected: The title should change to the path
Actual: It keeps showing the previous title

I tested using serve as the server.

Severity: -- → S3
Severity: S3 → S4

hmm, this is surprising at least from DOM side, since
https://searchfox.org/mozilla-central/rev/07342ce09126c513540c1c343476e026cfa907bf/dom/base/nsContentSink.cpp#1379 should reset title.

Kagami, could you perhaps check the title of the relevant docshell.
Browser Toolbox, select the right process and then
tabs[<the index of the tab>].content.docShell.QueryInterface(Components.interfaces.nsIBaseWindow).title

Flags: needinfo?(krosylight)

Both document.title and tabs[0].content.docShell.QueryInterface(Components.interfaces.nsIBaseWindow).title becomes an empty string.

It's WindowGlobalParent::RecvUpdateDocumentTitle that ignores empty string. if (mDocumentTitle == aTitle) becomes true and thus does not fire pagetitlechanged event.

Flags: needinfo?(krosylight)
Assignee: nobody → krosylight

This probably needs a test but not sure how to write one. The address shouldn't change but only the content should, do we currently have such tests?

(for comment #6)

Flags: needinfo?(bugs)

You mean the address shouldn't change but the title should?
Could the test be a mochitest which opens a new window where the actual test is run. After reload the test would check the title of the WindowGlobalParent in the parent process by using SpecialPowers' loadChromeScript.
Something like https://searchfox.org/mozilla-central/rev/03224522336f60a1a61a87e1fcd4feb0a0315a9b/dom/events/test/file_coalesce_touchmove.html#26-27

Flags: needinfo?(bugs)

No, WindowGlobalParent already gets an empty string (as its initial value, as reloading seemingly constructs a new WindowGlobalParent, or am I misunderstanding?) but it just doesn't fire the event, so getting WindowGlobalParent's title won't be helpful.

I think the test would have to access _gBrowser or alternatively directly listen the event, but the question is, can the test mutate the file before reloading?

Attachment #9197514 - Attachment description: Bug 1686194 - Fire pagetitlechanged when initialized with an empty string → Bug 1686194 - Fire pagetitlechanged when initialized with an empty string r=smaug
Pushed by krosylight@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4837c1efc868 Fire pagetitlechanged when initialized with an empty string r=smaug

Backed out for failures on browser_bug1686194.js

backout: https://hg.mozilla.org/integration/autoland/rev/a0f08b3d66e9ffd23c054f109d3d456ec855acaa

push: https://treeherder.mozilla.org/jobs?repo=autoland&revision=4837c1efc868542bec9107071809e481ade5e75c&group_state=expanded&test_paths=dom%2Fipc%2Ftests%2Fbrowser.ini&selectedTaskRun=DKIvmn3dT7CCLQROHsWIxw.0

failure log: https://treeherder.mozilla.org/logviewer?job_id=328098392&repo=autoland&lineNumber=6765

[task 2021-01-28T16:53:48.986Z] 16:53:48 INFO - TEST-PASS | dom/ipc/tests/browser_bug1686194.js | The title should be the raw path -
[task 2021-01-28T16:53:48.986Z] 16:53:48 INFO - Buffered messages finished
[task 2021-01-28T16:53:48.986Z] 16:53:48 INFO - TEST-UNEXPECTED-FAIL | dom/ipc/tests/browser_bug1686194.js | The title should change - Got "mochi.test:8888/browser/dom/ipc/tests/file_dummy.html", expected "Title"
[task 2021-01-28T16:53:48.986Z] 16:53:48 INFO - Stack trace:
[task 2021-01-28T16:53:48.986Z] 16:53:48 INFO - chrome://mochikit/content/browser-test.js:test_is:1351
[task 2021-01-28T16:53:48.986Z] 16:53:48 INFO - chrome://mochitests/content/browser/dom/ipc/tests/browser_bug1686194.js:null:31
[task 2021-01-28T16:53:48.986Z] 16:53:48 INFO - Not taking screenshot here: see the one that was previously logged
[task 2021-01-28T16:53:48.987Z] 16:53:48 INFO - TEST-UNEXPECTED-FAIL | dom/ipc/tests/browser_bug1686194.js | The title should be the raw path again -
[task 2021-01-28T16:53:48.987Z] 16:53:48 INFO - Stack trace:
[task 2021-01-28T16:53:48.987Z] 16:53:48 INFO - chrome://mochikit/content/browser-test.js:test_ok:1323
[task 2021-01-28T16:53:48.987Z] 16:53:48 INFO - chrome://mochitests/content/browser/dom/ipc/tests/browser_bug1686194.js:null:37
[task 2021-01-28T16:53:48.987Z] 16:53:48 INFO - Leaving test bound
[task 2021-01-28T16:53:49.017Z] 16:53:49 INFO - GECKO(8040) | MEMORY STAT | vsize 2104176MB | vsizeMaxContiguous 65587074MB | residentFast 238MB | heapAllocated 80MB
[task 2021-01-28T16:53:49.017Z] 16:53:49 INFO - TEST-OK | dom/ipc/tests/browser_bug1686194.js | took 426ms

Flags: needinfo?(krosylight)
Flags: needinfo?(krosylight)
Pushed by krosylight@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/bbbe2bf984fa Fire pagetitlechanged when initialized with an empty string r=smaug
Regressions: 1689429
Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch

I LOVE to see this community in action. :-)
Good job and thank you all!

Thank you for filing this issue! 😍

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: