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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>26295</bug_id>
          
          <creation_ts>2014-07-09 08:37:08 +0000</creation_ts>
          <short_desc>Page source not defined</short_desc>
          <delta_ts>2015-03-31 15:12:37 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Browser Test/Tools WG</product>
          <component>WebDriver</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>20860</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Andreas Tolfsen">ato</reporter>
          <assigned_to name="Browser Testing and Tools WG">public-browser-tools-testing</assigned_to>
          <cc>ato</cc>
    
    <cc>dburns</cc>
    
    <cc>mike</cc>
          
          <qa_contact name="Browser Testing and Tools WG">public-browser-tools-testing</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>108817</commentid>
    <comment_count>0</comment_count>
    <who name="Andreas Tolfsen">ato</who>
    <bug_when>2014-07-09 08:37:08 +0000</bug_when>
    <thetext>The command to get page source is not yet defined in the specification.  The DOM Parsing specification mentions an XMLSerializer interface which barancev says FirefoxDriver is already using:

    http://domparsing.spec.whatwg.org/#xmlserializer

The algorithm they use for XML serialization is here:

    http://domparsing.spec.whatwg.org/#concept-serialize-xml

It should be made clear in a note or something that the stringified DOM we return doesn&apos;t necessarily correctly reflect the active DOM as it would&apos;ve been seen if inspecting the DOM through a debugger.  With more tactful prose.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108820</commentid>
    <comment_count>1</comment_count>
      <attachid>1491</attachid>
    <who name="Andreas Tolfsen">ato</who>
    <bug_when>2014-07-09 13:18:43 +0000</bug_when>
    <thetext>Created attachment 1491
Example

After having examined this closer I think what we want is to call outerHTML on the documentElement instead, which “[…] represents the markup of the Element and its contents”:

    http://domparsing.spec.whatwg.org/#outerhtml

This seems to be closer to the intended behaviour of getting the current DOM and will work on both HTML and XHTML type documents.

So the spec should simply refer to the DOM Parsing spec&apos;s definition of outerHTML without making any special guarantees or promises.  We should however add a note saying something along the lines of this:

“Note: The details of the outerHTML serialization may be subject to user agent details.  For example the sequence order of attributes on DOM nodes is unspecified.”

There are also the following provisions in the spec about error handling:

  * Throws InvalidStateError if element in an XML document cannot be serialized to XML
  * Throws SyntaxError if the given string is not well-formed
  * Throws NoModificationAllowedError if the parent of the element is a document node

The two first are theoretical in our case as there&apos;s a limited number of XHTML documents out there that are both ill-formed /and/ which modify the DOM to become invalid at runtime.

The third is irrelevant in our case as we will always be calling this at the document.documentElement.

We could raise an &quot;invalid element state&quot; in this case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>119150</commentid>
    <comment_count>2</comment_count>
    <who name="David Burns :automatedtester">dburns</who>
    <bug_when>2015-03-31 15:12:37 +0000</bug_when>
    <thetext>it was decided not to add pageSource to the spefication so closing.

To get the same result the local end can do 

&gt; driver.executeScript(&quot;return document.querySelector(&apos;:root&apos;).outerHTML&quot;)</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>1491</attachid>
            <date>2014-07-09 13:18:43 +0000</date>
            <delta_ts>2014-07-09 13:18:43 +0000</delta_ts>
            <desc>Example</desc>
            <filename>page_source.py</filename>
            <type>text/x-python-script</type>
            <size>857</size>
            <attacher name="Andreas Tolfsen">ato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