Commit 3a899968 authored by Nate Chapin's avatar Nate Chapin Committed by Commit Bot

Save a form submission's origin document before scheduled the navigation task

If the form gets reparented, it should retain its old origin document.

Bug: 1063549
Test: fast/forms/reparent-form-during-planned-navigation-task.html
Change-Id: Ia4d2fbadc57b217dbc43ed2db26f6b38573726ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2118292
Commit-Queue: Nate Chapin <japhet@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarJoey Arhar <jarhar@chromium.org>
Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753317}
parent 452b03f6
......@@ -155,7 +155,8 @@ inline FormSubmission::FormSubmission(
ClientNavigationReason reason,
std::unique_ptr<ResourceRequest> resource_request,
Frame* target_frame,
WebFrameLoadType load_type)
WebFrameLoadType load_type,
Document* origin_document)
: method_(method),
action_(action),
target_(target),
......@@ -167,7 +168,8 @@ inline FormSubmission::FormSubmission(
reason_(reason),
resource_request_(std::move(resource_request)),
target_frame_(target_frame),
load_type_(load_type) {}
load_type_(load_type),
origin_document_(origin_document) {}
inline FormSubmission::FormSubmission(const String& result)
: method_(kDialogMethod), result_(result) {}
......@@ -322,12 +324,14 @@ FormSubmission* FormSubmission::Create(HTMLFormElement* form,
copied_attributes.Method(), action_url, target_or_base_target,
encoding_type, form, std::move(form_data), event,
frame_request.GetNavigationPolicy(), triggering_event_info, reason,
std::move(resource_request), target_frame, load_type);
std::move(resource_request), target_frame, load_type,
frame_request.OriginDocument());
}
void FormSubmission::Trace(Visitor* visitor) {
visitor->Trace(form_);
visitor->Trace(target_frame_);
visitor->Trace(origin_document_);
}
void FormSubmission::Navigate() {
......@@ -338,7 +342,7 @@ void FormSubmission::Navigate() {
}
resource_request_->SetUrl(request_url);
FrameLoadRequest frame_request(&form_->GetDocument(), *resource_request_);
FrameLoadRequest frame_request(origin_document_.Get(), *resource_request_);
frame_request.SetNavigationPolicy(navigation_policy_);
frame_request.SetClientRedirectReason(reason_);
frame_request.SetForm(form_);
......
......@@ -112,7 +112,8 @@ class FormSubmission final : public GarbageCollected<FormSubmission> {
ClientNavigationReason reason,
std::unique_ptr<ResourceRequest> resource_request,
Frame* target_frame,
WebFrameLoadType load_type);
WebFrameLoadType load_type,
Document* origin_document);
// FormSubmission for DialogMethod
explicit FormSubmission(const String& result);
......@@ -146,6 +147,7 @@ class FormSubmission final : public GarbageCollected<FormSubmission> {
std::unique_ptr<ResourceRequest> resource_request_;
Member<Frame> target_frame_;
WebFrameLoadType load_type_;
Member<Document> origin_document_;
};
} // namespace blink
......
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<iframe id="i" src="about:blank"></iframe>
<script>
async_test(t => {
var form = i.contentDocument.createElement('form');
form.action = '/common/blank.html';
i.contentDocument.body.appendChild(form);
i.onload = t.step_func_done(() => {});
form.submit();
new Document().prepend(form);
});
</script>
</body>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment