<?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>86077</bug_id>
          
          <creation_ts>2012-05-10 02:36:29 -0700</creation_ts>
          <short_desc>Viewport attribute values are leaked when document.write() is used.</short_desc>
          <delta_ts>2014-02-03 03:50:53 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Tools / Tests</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Qt, QtTriaged</keywords>
          <priority>P1</priority>
          <bug_severity>Critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>79668</blocked>
    
    <blocked>85425</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Csaba Osztrogonác">ossy</reporter>
          <assigned_to name="alan">zalan</assigned_to>
          <cc>hugo.lima</cc>
    
    <cc>kenneth</cc>
    
    <cc>kpiascik</cc>
    
    <cc>ossy</cc>
    
    <cc>tonikitoo</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>620404</commentid>
    <comment_count>0</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2012-05-10 02:36:29 -0700</bug_when>
    <thetext>The new assertion is introduced in r116571 and hit from the beginning.

crash log for DumpRenderTree (pid 21943):
STDOUT: &lt;empty&gt;
STDERR: ASSERTION FAILED: m_viewportArguments.type == ViewportArguments::Implicit
STDERR: ../../../../Source/WebCore/dom/Document.cpp(777) : void WebCore::Document::setDocType(WTF::PassRefPtr&lt;WebCore::DocumentType&gt;)
STDERR: 1   0x7fce283a07c8 /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::Document::setDocType(WTF::PassRefPtr&lt;WebCore::DocumentType&gt;)+0x11c) [0x7fce283a07c8]
STDERR: 2   0x7fce283eff6d /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::DocumentType::insertedInto(WebCore::Node*)+0x13f) [0x7fce283eff6d]
STDERR: 3   0x7fce28382258 /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::ChildNodeInsertionNotifier::notifyNodeInsertedIntoDocument(WebCore::Node*)+0x9a) [0x7fce28382258]
STDERR: 4   0x7fce283823d7 /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::ChildNodeInsertionNotifier::notifyInsertedIntoDocument(WebCore::Node*)+0x23) [0x7fce283823d7]
STDERR: 5   0x7fce28384e3f /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::ContainerNode::parserAddChild(WTF::PassRefPtr&lt;WebCore::Node&gt;)+0x14d) [0x7fce28384e3f]
STDERR: 6   0x7fce28665d82 /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(+0x25aed82) [0x7fce28665d82]
STDERR: 7   0x7fce28666144 /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::HTMLConstructionSite::executeQueuedTasks()+0x76) [0x7fce28666144]
STDERR: 8   0x7fce28666f99 /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::HTMLConstructionSite::insertDoctype(WebCore::AtomicHTMLToken&amp;)+0x2b5) [0x7fce28666f99]
STDERR: 9   0x7fce2868eeaa /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::HTMLTreeBuilder::processDoctypeToken(WebCore::AtomicHTMLToken&amp;)+0x86) [0x7fce2868eeaa]
STDERR: 10  0x7fce2868ed89 /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::HTMLTreeBuilder::processToken(WebCore::AtomicHTMLToken&amp;)+0xa5) [0x7fce2868ed89]
STDERR: 11  0x7fce2868ebe8 /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::HTMLTreeBuilder::constructTreeFromAtomicToken(WebCore::AtomicHTMLToken&amp;)+0x50) [0x7fce2868ebe8]
STDERR: 12  0x7fce2868eae2 /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::HTMLTreeBuilder::constructTreeFromToken(WebCore::HTMLToken&amp;)+0x66) [0x7fce2868eae2]
STDERR: 13  0x7fce2866df3b /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::HTMLDocumentParser::pumpTokenizer(WebCore::HTMLDocumentParser::SynchronousMode)+0x327) [0x7fce2866df3b]
STDERR: 14  0x7fce2866d801 /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::HTMLDocumentParser::pumpTokenizerIfPossible(WebCore::HTMLDocumentParser::SynchronousMode)+0xb1) [0x7fce2866d801]
STDERR: 15  0x7fce2866e370 /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::HTMLDocumentParser::insert(WebCore::SegmentedString const&amp;)+0xa4) [0x7fce2866e370]
STDERR: 16  0x7fce283a8b5a /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::Document::write(WebCore::SegmentedString const&amp;, WebCore::Document*)+0x1ac) [0x7fce283a8b5a]
STDERR: 17  0x7fce2811143e /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(+0x205a43e) [0x7fce2811143e]
STDERR: 18  0x7fce281114dd /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::JSHTMLDocument::write(JSC::ExecState*)+0x33) [0x7fce281114dd]
STDERR: 19  0x7fce29281fc7 /home/webkitbuildbot/slaves/debug64bit/buildslave/qt-linux-64-debug/build/WebKitBuild/Debug/lib/libQtWebKit.so.4(WebCore::jsHTMLDocumentPrototypeFunctionWrite(JSC::ExecState*)+0x12b) [0x7fce29281fc7]
STDERR: 20  0x7fcddc620265 [0x7fcddc620265]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>620415</commentid>
    <comment_count>1</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2012-05-10 02:55:32 -0700</bug_when>
    <thetext>looking at it now</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>620492</commentid>
    <comment_count>2</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2012-05-10 05:27:09 -0700</bug_when>
    <thetext>1, Document is reused multiple times by injecting new content using document.write(). 
2, content A has xhtml-mobile dtd and document sets the legacy viewport attributes.
3, content B comes and assert hits because the viewport attribute type leaks from content A.

it&apos;s good that the type check was replaced by the assert, as with the type check, we would have missed proper viewport attribute adaptation, while content A with &apos;meta viewport&apos; -&gt; content B with &apos;xhtml-mobile&apos; transition.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>620589</commentid>
    <comment_count>3</comment_count>
      <attachid>141173</attachid>
    <who name="alan">zalan</who>
    <bug_when>2012-05-10 08:07:54 -0700</bug_when>
    <thetext>Created attachment 141173
test case</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>621333</commentid>
    <comment_count>4</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2012-05-11 00:15:47 -0700</bug_when>
    <thetext>I skipped the asserting test - https://trac.webkit.org/changeset/116734
Please unskip it with the proper fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>622884</commentid>
    <comment_count>5</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2012-05-14 06:07:36 -0700</bug_when>
    <thetext>this gets a little bit more generic:

given the following meta 
&lt;meta id=&quot;viewport&quot; name=&apos;viewport&apos; content=&apos;width=device-width&apos;&gt;

these 2 calls both update viewport values to default:
document.getElementById(&quot;viewport&quot;).setAttribute(&quot;content&quot;, &quot;&quot;);
document.getElementsByTagName(&quot;meta&quot;)[0].content=&apos;&apos;;

however, none of the calls below initiate viewport value update:
a, var vp = document.getElementById(&quot;viewport&quot;); vp.parentNode.removeChild(vp);
b, document.getElementsByTagName(&quot;head&quot;)[0].innerHTML = &quot;&quot;;

or even when the entire content of the document is trashed using
document.open() -&gt; document.write()

Shouldn&apos;t dynamically removed meta viewport initiate update on the viewport values similarly when the &apos;content&apos; attribute is changed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>622947</commentid>
    <comment_count>6</comment_count>
    <who name="Kenneth Rohde Christiansen">kenneth</who>
    <bug_when>2012-05-14 07:06:36 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; this gets a little bit more generic:
&gt; 
&gt; given the following meta 
&gt; &lt;meta id=&quot;viewport&quot; name=&apos;viewport&apos; content=&apos;width=device-width&apos;&gt;
&gt; 
&gt; these 2 calls both update viewport values to default:
&gt; document.getElementById(&quot;viewport&quot;).setAttribute(&quot;content&quot;, &quot;&quot;);
&gt; document.getElementsByTagName(&quot;meta&quot;)[0].content=&apos;&apos;;
&gt; 
&gt; however, none of the calls below initiate viewport value update:
&gt; a, var vp = document.getElementById(&quot;viewport&quot;); vp.parentNode.removeChild(vp);
&gt; b, document.getElementsByTagName(&quot;head&quot;)[0].innerHTML = &quot;&quot;;
&gt; 
&gt; or even when the entire content of the document is trashed using
&gt; document.open() -&gt; document.write()
&gt; 
&gt; Shouldn&apos;t dynamically removed meta viewport initiate update on the viewport values similarly when the &apos;content&apos; attribute is changed?

This sounds sensible to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>628349</commentid>
    <comment_count>7</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2012-05-18 21:19:44 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; (In reply to comment #5)
&gt; &gt; this gets a little bit more generic:
&gt; &gt; 
&gt; &gt; given the following meta 
&gt; &gt; &lt;meta id=&quot;viewport&quot; name=&apos;viewport&apos; content=&apos;width=device-width&apos;&gt;
&gt; &gt; 
&gt; &gt; these 2 calls both update viewport values to default:
&gt; &gt; document.getElementById(&quot;viewport&quot;).setAttribute(&quot;content&quot;, &quot;&quot;);
&gt; &gt; document.getElementsByTagName(&quot;meta&quot;)[0].content=&apos;&apos;;
&gt; &gt; 
&gt; &gt; however, none of the calls below initiate viewport value update:
&gt; &gt; a, var vp = document.getElementById(&quot;viewport&quot;); vp.parentNode.removeChild(vp);
&gt; &gt; b, document.getElementsByTagName(&quot;head&quot;)[0].innerHTML = &quot;&quot;;
&gt; &gt; 
&gt; &gt; or even when the entire content of the document is trashed using
&gt; &gt; document.open() -&gt; document.write()
&gt; &gt; 
&gt; &gt; Shouldn&apos;t dynamically removed meta viewport initiate update on the viewport values similarly when the &apos;content&apos; attribute is changed?
&gt; 
&gt; This sounds sensible to me.

+1. how does firefox mobile or opera behavior with dynamic viewport values?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>630355</commentid>
    <comment_count>8</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2012-05-22 07:40:05 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; (In reply to comment #6)
&gt; &gt; (In reply to comment #5)
&gt; &gt; &gt; this gets a little bit more generic:
&gt; &gt; &gt; 
&gt; &gt; &gt; given the following meta 
&gt; &gt; &gt; &lt;meta id=&quot;viewport&quot; name=&apos;viewport&apos; content=&apos;width=device-width&apos;&gt;
&gt; &gt; &gt; 
&gt; &gt; &gt; these 2 calls both update viewport values to default:
&gt; &gt; &gt; document.getElementById(&quot;viewport&quot;).setAttribute(&quot;content&quot;, &quot;&quot;);
&gt; &gt; &gt; document.getElementsByTagName(&quot;meta&quot;)[0].content=&apos;&apos;;
&gt; &gt; &gt; 
&gt; &gt; &gt; however, none of the calls below initiate viewport value update:
&gt; &gt; &gt; a, var vp = document.getElementById(&quot;viewport&quot;); vp.parentNode.removeChild(vp);
&gt; &gt; &gt; b, document.getElementsByTagName(&quot;head&quot;)[0].innerHTML = &quot;&quot;;
&gt; &gt; &gt; 
&gt; &gt; &gt; or even when the entire content of the document is trashed using
&gt; &gt; &gt; document.open() -&gt; document.write()
&gt; &gt; &gt; 
&gt; &gt; &gt; Shouldn&apos;t dynamically removed meta viewport initiate update on the viewport values similarly when the &apos;content&apos; attribute is changed?
&gt; &gt; 
&gt; &gt; This sounds sensible to me.
&gt; 
&gt; +1. how does firefox mobile or opera behavior with dynamic viewport values?
FF mobile(14.0?) on Android(4.0.4) does not seem to be supporting any dynamic change of the viewport values (and it is broken in so many ways)
However, Opera mobile(12.0) on Android(4.0.4) seems to be supporting changing the viewport values with 
1, setAttribute, 
2, removing the viewport using removeChild() -though it gets confused with multiple viewport metas.
3, emptying the &lt;head&gt; using  document.getElementsByTagName(&quot;head&quot;)[0].innerHTML = &quot;&quot;;
4, and even using document.write() -though the new content&apos;s viewport values are ignored, so it looks like it just resets the viewport to default (as if no meta present)

So Opera mobile clearly reacts on when the meta tag changes unlike us (other than the setAttribute())</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>630366</commentid>
    <comment_count>9</comment_count>
    <who name="alan">zalan</who>
    <bug_when>2012-05-22 07:49:48 -0700</bug_when>
    <thetext>We need to be clever about this though as multiple viewport meta tags in the document can make things complicated, such as

1, changing the ignored ones should not have any impact on the viewport. 
2, after removing the one was in use, some priority order need to be checked to see which one to take next.
3, adding a new one might or might not change the actual viewport values. (later when we introduce legacy tags to get converted into viewport values)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>975828</commentid>
    <comment_count>10</comment_count>
    <who name="Jocelyn Turcotte">jturcotte</who>
    <bug_when>2014-02-03 03:50:53 -0800</bug_when>
    <thetext>=== Bulk closing of Qt bugs ===

If you believe that this bug report is still relevant for a non-Qt port of webkit.org, please re-open it.

If you believe that this is still an important QtWebKit bug, please fill a new report at https://bugreports.qt-project.org and add a link to this issue. See http://qt-project.org/wiki/ReportingBugsInQt for additional guidelines.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>141173</attachid>
            <date>2012-05-10 08:07:54 -0700</date>
            <delta_ts>2012-05-10 08:07:54 -0700</delta_ts>
            <desc>test case</desc>
            <filename>xhtmlmobiledtd.html</filename>
            <type>text/html</type>
            <size>346</size>
            <attacher name="alan">zalan</attacher>
            
              <data encoding="base64">PGh0bWw+CjxoZWFkPgogIDxtZXRhIG5hbWU9J3ZpZXdwb3J0JyBjb250ZW50PSd3aWR0aD1kZXZp
Y2Utd2lkdGgnPgogIDxzY3JpcHQ+CiAgICAgZnVuY3Rpb24gZm9vKCkgewogICAgICAgZG9jdW1l
bnQud3JpdGUoJzwhRE9DVFlQRSBodG1sIFBVQkxJQyAiLS8vV0FQRk9SVU0vL0RURCBYSFRNTCBN
b2JpbGUgMS4xLy9FTiIgImh0dHA6Ly93d3cub3Blbm1vYmlsZWFsbGlhbmNlLm9yZy90ZWNoL0RU
RC94aHRtbC1tb2JpbGUxMS5kdGQiPjxodG1sPjxib2R5PjwvYm9keT48L2h0bWw+Jyk7CiAgICAg
fQogIDwvc2NyaXB0Pgo8L2hlYWQ+Cjxib2R5IG9ubG9hZD0nZm9vKCk7Jz4KPC9ib2R5Pgo8L2h0
bWw+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>