New issue
Advanced search Search tips

Issue 819857 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Mar 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 3
Type: Bug



Sign in to add a comment

<body> in iframe gets unexpected margins

Project Member Reported by bokan@chromium.org, Mar 8 2018

Issue description

Chrome Version       : ToT
OS Version: Linux

I'm seeing some puzzling results which I can't explain but I'm unfamiliar with layout and style internals so apologies if this is my mistake and not a bug.

Here's two tests I have:

TEST_F(Test, Pass) {
  SetBodyInnerHTML(R"HTML(
    <!DOCTYPE html>
    <style>html, body{margin:0; padding: 0;}</style>
    <iframe marginheight="0" marginwidth="0" srcdoc="<!DOCTYPE html><style>html, body{margin:0; padding: 0;}</style>">
    </iframe>
  )HTML");

  // PASSES
  EXPECT_EQ(LayoutPoint(0, 0),
      ToLayoutBox(GetDocument().body()->GetLayoutObject())->Location());

  LocalFrame* child_frame =
      ToLocalFrame(GetDocument().GetFrame()->Tree().FirstChild());

  // PASSES
  EXPECT_EQ(LayoutPoint(0, 0),
      ToLayoutBox(child_frame->GetDocument()->body()->GetLayoutObject())->Location());
}

TEST_F(Test, Fail) {
  SetBodyInnerHTML(R"HTML(
    <!DOCTYPE html>
    <style>html, body{margin:0; padding: 0;}</style>
    <iframe srcdoc="<!DOCTYPE html><style>html, body{margin:0; padding: 0;}</style>">
    </iframe>
  )HTML");

  // PASSES
  EXPECT_EQ(LayoutPoint(0, 0),
      ToLayoutBox(GetDocument().body()->GetLayoutObject())->Location());

  LocalFrame* child_frame =
      ToLocalFrame(GetDocument().GetFrame()->Tree().FirstChild());

  // FAILS
  EXPECT_EQ(LayoutPoint(0, 0),
      ToLayoutBox(child_frame->GetDocument()->body()->GetLayoutObject())->Location());
}

The first one passes but the second one fails. It seems that the iframe body's LayoutObject gets margins applied to it even though I've cleared out the margin via style. It works correctly when the deprecated marginheight and marginwidth attributes are set. Intuitively, I would expect these to be equivalent.

Digging a bit deeper in the failing test, in the SetBodyInnerHTML landed in LayoutBox::ComputeAndSetBlockDirectionMargins (this == body) and its StyleRef().MarginBefore() and MarginAfter() are 8px.

Most curiously, this doesn't seem to be a problem when loaded into my dev-channel browser. So either there's an issue in the test environment or I'm misinterpreting something pretty badly.
 
Cc: emilio@chromium.org
Wild guess - maybe the inner frame hasn't finished loading, or hasn't updated its lifecycle?

Comment 3 by bokan@chromium.org, Mar 8 2018

Status: WontFix (was: Untriaged)
It is loaded, has DOM and done a lifecycle update but you're right - it hasn't parsed the srcset into DOM yet and I'm not sure how to get it to do that. Adding testing::RunPendingTasks() doesn't help. Any ideas?

I'll close this since it isn't a bug - thanks for looking, sorry for the noise.

Sign in to add a comment