Closed Bug 916667 Opened 11 years ago Closed 11 years ago

about:tabcrashed fails to display on pages without a title

Categories

(Firefox :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 27

People

(Reporter: markh, Assigned: Felipe)

Details

Attachments

(3 files, 1 obsolete file)

If a crashing page has no title, nsDocShell::DisplayLoadError fails with NS_ERROR_FAILURE.  This is because the string in the 'crashedPageTitle' is empty, so it attempts to fetch the message 'tabcrashed' from the string bundle, which doesn't exist:

JavaScript error: chrome://browser/content/tabbrowser.xml, line 3124: NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDocShell.displayLoadError]
This patch uses the URI if no title is available.
Assignee: nobody → mhammond
Status: NEW → ASSIGNED
Attachment #805151 - Flags: review?
setTabTitle does a few more things:
http://mxr.mozilla.org/mozilla-central/source/browser/base/content/tabbrowser.xml#1187

Should we do those things here too? (factored out into a helper maybe)
(In reply to :Gavin Sharp (use gavin@gavinsharp.com for email) from comment #2)
> setTabTitle does a few more things:
> http://mxr.mozilla.org/mozilla-central/source/browser/base/content/
> tabbrowser.xml#1187
> 
> Should we do those things here too? (factored out into a helper maybe)

Yeah, I guess we should.  This patch creates a helper _titleForBrowser(aBrowser) - sadly, it needs to return 2 values - the title itself and a boolean to indicate if the title came from the URI - setTabTitle() cares about the boolean so it can change the 'crop' attribute of the tab if necessary.

The patch has come out a little weird - it looks like I moved 2 unrelated functions, but hopefully it can be untangled :)
Attachment #805151 - Attachment is obsolete: true
Attachment #805151 - Flags: review?
Attachment #805812 - Flags: review?(felipc)
Comment on attachment 805812 [details] [diff] [review]
0001-Bug-916667-Refactor-and-reuse-the-logic-in-setTabTit.patch

This should already work, I added a string to the string bundle specifically for this case! see here:

http://mxr.mozilla.org/mozilla-central/source/dom/locales/en-US/chrome/appstrings.properties#37

but.. I only added it to dom/.../appstrings.properties and didn't notice that the browser one overrides it (http://mxr.mozilla.org/mozilla-central/source/browser/locales/en-US/chrome/overrides/appstrings.properties)
Attachment #805812 - Flags: review?(felipc)
Attached patch PatchSplinter Review
I added the missing string to the browser/ version of appstrings.properties, but turns out that's not enough. I thought that the existence of the string id in the bundle would be enough, but the code in nsDocShell really wants a non-empty string, otherwise it will return an error.

This will make the page set " " as the document title, but the front-end trims it and considers it as a page with no title, and do the right thing (no page title -> display url)
Attachment #806214 - Flags: review?(gavin.sharp)
Attachment #806214 - Flags: review?(mhammond)
Comment on attachment 806214 [details] [diff] [review]
Patch

Review of attachment 806214 [details] [diff] [review]:
-----------------------------------------------------------------

As discussed on IRC, the addition of the new string wasn't supposed to be included.  r=me with that removed, plus a comment added to nsDocShell saying both that (a) UX wants no title and (b) attempting to add an empty string to the .properties file doesn't do the right thing.
Attachment #806214 - Flags: review?(mhammond) → review+
Comment on attachment 806214 [details] [diff] [review]
Patch

Thanks. I'll also write a test for this before landing
Attachment #806214 - Flags: review?(gavin.sharp)
Assignee: mhammond → felipc
Attached patch Patch w/ testSplinter Review
The test took a frustratingly long time to get right, so it deserves a review. There's also a new check for childMap != null added, which will not happen in a real scenario, but happens during the tests so it's there to avoid the null error msg from poluting the test.
Attachment #808740 - Flags: review?(mhammond)
Comment on attachment 808740 [details] [diff] [review]
Patch w/ test

As this adds a new folder for mochitest-chrome tests in browser, it needs a build peer review
Attachment #808740 - Flags: review?(mh+mozilla)
Comment on attachment 808740 [details] [diff] [review]
Patch w/ test

Review of attachment 808740 [details] [diff] [review]:
-----------------------------------------------------------------

for the build parts
Attachment #808740 - Flags: review?(mh+mozilla) → review+
Comment on attachment 808740 [details] [diff] [review]
Patch w/ test

Review of attachment 808740 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM!  Ideally we'd also have a test that a crash does actually show the page, but I think that would be fine to have in a followup - it's subtle (as we saw recently with thumbnail crash tests and ASan) and we don't really have the test infrastructure in place for that yet.

::: docshell/base/nsDocShell.cpp
@@ +4347,5 @@
>          nsCOMPtr<Element> element = do_QueryInterface(handler);
>          element->GetAttribute(NS_LITERAL_STRING("crashedPageTitle"), messageStr);
>        }
> +
> +      if (messageStr.IsEmpty()) {

I think it is worth a comment about why we need to do this.
Attachment #808740 - Flags: review?(mhammond) → review+
https://hg.mozilla.org/mozilla-central/rev/3eb8450ae7d6
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 27
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: