mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #10821 - askeing:fix_10782, r=jdm
Checking the browsing_context before change title fix #10782 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10821) <!-- Reviewable:end -->
This commit is contained in:
commit
17ba9fb5da
4 changed files with 46 additions and 3 deletions
|
@ -624,10 +624,12 @@ impl Document {
|
|||
|
||||
/// Handles any updates when the document's title has changed.
|
||||
pub fn title_changed(&self) {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsertitlechange
|
||||
self.trigger_mozbrowser_event(MozBrowserEvent::TitleChange(String::from(self.Title())));
|
||||
if self.browsing_context().is_some() {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsertitlechange
|
||||
self.trigger_mozbrowser_event(MozBrowserEvent::TitleChange(String::from(self.Title())));
|
||||
|
||||
self.send_title_to_compositor();
|
||||
self.send_title_to_compositor();
|
||||
}
|
||||
}
|
||||
|
||||
/// Sends this document's title to the compositor.
|
||||
|
|
|
@ -6526,6 +6526,12 @@
|
|||
"url": "/_mozilla/mozilla/mozbrowser/mozbrowsershowmodalprompt_event.html"
|
||||
}
|
||||
],
|
||||
"mozilla/mozbrowser/mozbrowsertitlechangedeagerly_event.html": [
|
||||
{
|
||||
"path": "mozilla/mozbrowser/mozbrowsertitlechangedeagerly_event.html",
|
||||
"url": "/_mozilla/mozilla/mozbrowser/mozbrowsertitlechangedeagerly_event.html"
|
||||
}
|
||||
],
|
||||
"mozilla/mozbrowser/redirect.html": [
|
||||
{
|
||||
"path": "mozilla/mozbrowser/redirect.html",
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>Check if title_changed is too eager (issue #10782)</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<body></body>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.mozbrowser = "true";
|
||||
iframe.src = "mozbrowsertitlechangedeagerly_event_iframe.html";
|
||||
iframe.addEventListener("mozbrowsertitlechange", t.step_func(e => {
|
||||
assert_equals(e.type, "mozbrowsertitlechange");
|
||||
assert_not_equals(e.detail, "Bar");
|
||||
}));
|
||||
iframe.addEventListener("load", t.step_func_done());
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,16 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Foo</title>
|
||||
<script>
|
||||
var text =
|
||||
'<html xmlns="http://www.w3.org/1999/xhtml">' +
|
||||
' <head>' +
|
||||
' <title>Bar</title>' +
|
||||
' </head>' +
|
||||
'</html>';
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString(text, "text/xml");
|
||||
</script>
|
||||
</head>
|
||||
<body>Hello world</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue