<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>149889</bug_id>
          
          <creation_ts>2015-10-07 13:09:10 -0700</creation_ts>
          <short_desc>Wrong viewport in iframes</short_desc>
          <delta_ts>2026-10-12 07:20:38 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>Safari 9</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 9.0</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=266235</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Aleksandr Dobkin">dobkin</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>benjamin</cc>
    
    <cc>fred.wang</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1131380</commentid>
    <comment_count>0</comment_count>
    <who name="Aleksandr Dobkin">dobkin</who>
    <bug_when>2015-10-07 13:09:10 -0700</bug_when>
    <thetext>When a page is embedded in an iframe, the viewport expands to the size of the iframe, which causes some pages to render in Desktop mode instead of Mobile.

For example, the following page always renders in &apos;MOBILE&apos; mode on e.g. Mobile Safari on iPhones.

  &lt;!DOCTYPE html&gt;
  &lt;head&gt;
    &lt;meta content=&quot;width=device-width&quot; name=&quot;viewport&quot;&gt;
    &lt;style&gt;
      body::after {
        content: &quot;DESKTOP&quot;
      }
      @media (max-width:767px) {
        body::after {
          content: &quot;MOBILE&quot;
        }
      }
    &lt;/style&gt;
  &lt;/head&gt;
  &lt;div style=&quot;width: 1000px; border: 1px solid blue;&quot;&gt;
    very wide element
  &lt;/div&gt;

See this in action at http://output.jsbin.com/tizisoxidu. However, when the same page is embedded in an iframe, it renders in &apos;DESKTOP&apos; mode:

  &lt;!DOCTYPE html&gt;
  &lt;head&gt;
    &lt;meta content=&quot;width=device-width&quot; name=&quot;viewport&quot;&gt;
  &lt;/head&gt;
  &lt;iframe src=&quot;//output.jsbin.com/tizisoxidu&quot;&gt;&lt;/iframe&gt;


See this at http://output.jsbin.com/qagelujucu.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1131518</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2015-10-07 19:59:04 -0700</bug_when>
    <thetext>&gt; the viewport expands to the size of the iframe
This is frame flattening, which we do by default on iOS. We also don&apos;t do anything with &lt;meta name=&quot;viewport&quot;&gt; tags in iframes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1131750</commentid>
    <comment_count>2</comment_count>
    <who name="Aleksandr Dobkin">dobkin</who>
    <bug_when>2015-10-08 15:23:37 -0700</bug_when>
    <thetext>Note that in the top-level/parent frame, the viewport width never changes. So even if the size of the content, including interior iframes, becomes very large, the viewport remains at e.g. 320px and mobile rendering is maintained. However, once the content is put into an iframe, it ends up rendering much differently depending on the CSS rules that are used.

One idea to fix this while keeping flattening would be make the CSS viewport size in frames to equal the nominal size of the frame. For example, if the iframe width is specified to be &apos;100px&apos;, &apos;100vw&apos;, or &apos;100%&apos;, the viewport would be fixed to the corresponding pixel sizes, at least for the purpose of CSS media queries.

This is pretty difficult to work around currently. I&apos;m not aware of any way to to disable flattening for a particular frame. The only reasonable workaround I&apos;m aware of is either 1) to create scrolling element and put the extra-wide content inside it, but that requires changing the DOM of the iframe, or 2) disable horizontal scrolling, but this really not ideal.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2262514</commentid>
    <comment_count>3</comment_count>
      <attachid>481765</attachid>
    <who name="Frédéric Wang Nélar">fred.wang</who>
    <bug_when>2026-10-12 07:15:55 -0700</bug_when>
    <thetext>Created attachment 481765
testcase</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2262516</commentid>
    <comment_count>4</comment_count>
      <attachid>481766</attachid>
    <who name="Frédéric Wang Nélar">fred.wang</who>
    <bug_when>2026-10-12 07:18:15 -0700</bug_when>
    <thetext>Created attachment 481766
testcase 2</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2262517</commentid>
    <comment_count>5</comment_count>
    <who name="Frédéric Wang Nélar">fred.wang</who>
    <bug_when>2026-10-12 07:20:38 -0700</bug_when>
    <thetext>both testcase and testcase 2 renders as &quot;MOBILE&quot; on ios simulator.

I think frame flattening has been removed after bug 195622 / bug 242883.

So closing this bug but feel free to reopen if that&apos;s incorrect.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>481765</attachid>
            <date>2026-10-12 07:15:55 -0700</date>
            <delta_ts>2026-10-12 07:15:55 -0700</delta_ts>
            <desc>testcase</desc>
            <filename>bug-149889.html</filename>
            <type>text/html</type>
            <size>359</size>
            <attacher name="Frédéric Wang Nélar">fred.wang</attacher>
            
              <data encoding="base64">IDwhRE9DVFlQRSBodG1sPgogIDxoZWFkPgogICAgPG1ldGEgY29udGVudD0id2lkdGg9ZGV2aWNl
LXdpZHRoIiBuYW1lPSJ2aWV3cG9ydCI+CiAgICA8c3R5bGU+CiAgICAgIGJvZHk6OmFmdGVyIHsK
ICAgICAgICBjb250ZW50OiAiREVTS1RPUCIKICAgICAgfQogICAgICBAbWVkaWEgKG1heC13aWR0
aDo3NjdweCkgewogICAgICAgIGJvZHk6OmFmdGVyIHsKICAgICAgICAgIGNvbnRlbnQ6ICJNT0JJ
TEUiCiAgICAgICAgfQogICAgICB9CiAgICA8L3N0eWxlPgogIDwvaGVhZD4KICA8ZGl2IHN0eWxl
PSJ3aWR0aDogMTAwMHB4OyBib3JkZXI6IDFweCBzb2xpZCBibHVlOyI+CiAgICB2ZXJ5IHdpZGUg
ZWxlbWVudAogIDwvZGl2Pgo=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>481766</attachid>
            <date>2026-10-12 07:18:15 -0700</date>
            <delta_ts>2026-10-12 07:18:15 -0700</delta_ts>
            <desc>testcase 2</desc>
            <filename>bug-149889.html</filename>
            <type>text/html</type>
            <size>481</size>
            <attacher name="Frédéric Wang Nélar">fred.wang</attacher>
            
              <data encoding="base64">ICA8IURPQ1RZUEUgaHRtbD4KICA8aGVhZD4KICAgIDxtZXRhIGNvbnRlbnQ9IndpZHRoPWRldmlj
ZS13aWR0aCIgbmFtZT0idmlld3BvcnQiPgogIDwvaGVhZD4KICA8aWZyYW1lIHNyY2RvYz0nPCFE
T0NUWVBFIGh0bWw+CiAgPGhlYWQ+CiAgICA8bWV0YSBjb250ZW50PSJ3aWR0aD1kZXZpY2Utd2lk
dGgiIG5hbWU9InZpZXdwb3J0Ij4KICAgIDxzdHlsZT4KICAgICAgYm9keTo6YWZ0ZXIgewogICAg
ICAgIGNvbnRlbnQ6ICJERVNLVE9QIgogICAgICB9CiAgICAgIEBtZWRpYSAobWF4LXdpZHRoOjc2
N3B4KSB7CiAgICAgICAgYm9keTo6YWZ0ZXIgewogICAgICAgICAgY29udGVudDogIk1PQklMRSIK
ICAgICAgICB9CiAgICAgIH0KICAgIDwvc3R5bGU+CiAgPC9oZWFkPgogIDxkaXYgc3R5bGU9Indp
ZHRoOiAxMDAwcHg7IGJvcmRlcjogMXB4IHNvbGlkIGJsdWU7Ij4KICAgIHZlcnkgd2lkZSBlbGVt
ZW50CiAgPC9kaXY+Cic+PC9pZnJhbWU+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>