Merge inbound to mozilla-central. a=merge
authorCiure Andrei <aciure@mozilla.com>
Wed, 07 Aug 2019 00:42:56 +0300
changeset 486622 fb699b3c084c8d35e52f2b282de90ecb7b0992cd
parent 486621 20688459a2572d79ccc77ab030c2f67e8baff591 (current diff)
parent 486620 9fa080a464cb6053eedbba7e1460569114935551 (diff)
child 486623 0becabb6cd5be7b8f3c7a042063e91abad23e50b
child 486678 3011b29e256265bb4f5a9f53feb070b834f1922e
push id91835
push useraciure@mozilla.com
push dateTue, 06 Aug 2019 21:52:00 +0000
treeherderautoland@0becabb6cd5b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone70.0a1
first release with
nightly linux32
fb699b3c084c / 70.0a1 / 20190806214332 / files
nightly linux64
fb699b3c084c / 70.0a1 / 20190806214332 / files
nightly mac
fb699b3c084c / 70.0a1 / 20190806214332 / files
nightly win32
fb699b3c084c / 70.0a1 / 20190806214332 / files
nightly win64
fb699b3c084c / 70.0a1 / 20190806214332 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge inbound to mozilla-central. a=merge
--- a/dom/html/ImageDocument.cpp
+++ b/dom/html/ImageDocument.cpp
@@ -652,17 +652,17 @@ void ImageDocument::UpdateSizeFromLayout
 }
 
 nsresult ImageDocument::CreateSyntheticDocument() {
   // Synthesize an html document that refers to the image
   nsresult rv = MediaDocument::CreateSyntheticDocument();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Add the image element
-  Element* body = GetBodyElement();
+  RefPtr<Element> body = GetBodyElement();
   if (!body) {
     NS_WARNING("no body on image document!");
     return NS_ERROR_FAILURE;
   }
 
   RefPtr<mozilla::dom::NodeInfo> nodeInfo;
   nodeInfo = mNodeInfoManager->GetNodeInfo(
       nsGkAtoms::img, nullptr, kNameSpaceID_XHTML, nsINode::ELEMENT_NODE);
--- a/dom/html/PluginDocument.cpp
+++ b/dom/html/PluginDocument.cpp
@@ -185,17 +185,17 @@ nsresult PluginDocument::CreateSynthetic
   NS_ASSERTION(!GetPresShell() || !GetPresShell()->DidInitialize(),
                "Creating synthetic plugin document content too late");
 
   // make our generic document
   nsresult rv = MediaDocument::CreateSyntheticDocument();
   NS_ENSURE_SUCCESS(rv, rv);
   // then attach our plugin
 
-  Element* body = GetBodyElement();
+  RefPtr<Element> body = GetBodyElement();
   if (!body) {
     NS_WARNING("no body on plugin document!");
     return NS_ERROR_FAILURE;
   }
 
   // remove margins from body
   NS_NAMED_LITERAL_STRING(zero, "0");
   body->SetAttr(kNameSpaceID_None, nsGkAtoms::marginwidth, zero, false);
--- a/dom/html/VideoDocument.cpp
+++ b/dom/html/VideoDocument.cpp
@@ -97,17 +97,17 @@ void VideoDocument::SetScriptGlobalObjec
       LinkScript(NS_LITERAL_STRING(
           "chrome://global/content/TopLevelVideoDocument.js"));
     }
     InitialSetupDone();
   }
 }
 
 nsresult VideoDocument::CreateVideoElement() {
-  Element* body = GetBodyElement();
+  RefPtr<Element> body = GetBodyElement();
   if (!body) {
     NS_WARNING("no body on video document!");
     return NS_ERROR_FAILURE;
   }
 
   // make content
   RefPtr<mozilla::dom::NodeInfo> nodeInfo;
   nodeInfo = mNodeInfoManager->GetNodeInfo(
--- a/testing/web-platform/meta/feature-policy/reporting/encrypted-media-report-only.https.html.ini
+++ b/testing/web-platform/meta/feature-policy/reporting/encrypted-media-report-only.https.html.ini
@@ -1,9 +1,12 @@
 [encrypted-media-report-only.https.html]
+  disabled:
+    if debug and (os == "win") and bits == 64 and (processor == "aarch64"): https://bugzilla.mozilla.org/show_bug.cgi?id=1567706
+
   expected:
     if (os == "android") and not e10s: OK
     if (os == "win") and (processor == "aarch64"): OK
     if (os == "android") and e10s: OK
     TIMEOUT
   [Encrypted Media report only mode]
     expected:
       if (os == "android") and not e10s: FAIL
--- a/testing/web-platform/tests/webdriver/tests/execute_async_script/collections.py
+++ b/testing/web-platform/tests/webdriver/tests/execute_async_script/collections.py
@@ -58,33 +58,35 @@ def test_file_list(session, tmpdir):
 
 def test_html_all_collection(session):
     session.url = inline("""
         <p>foo
         <p>bar
         """)
     html = session.find.css("html", all=False)
     head = session.find.css("head", all=False)
+    meta = session.find.css("meta", all=False)
     body = session.find.css("body", all=False)
     ps = session.find.css("p")
 
     response = execute_async_script(session, """
         let resolve = arguments[0];
         resolve(document.all);
         """)
     value = assert_success(response)
     assert isinstance(value, list)
-    # <html>, <head>, <body>, <p>, <p>
-    assert len(value) == 5
+    # <html>, <head>, <meta>, <body>, <p>, <p>
+    assert len(value) == 6
 
     assert_same_element(session, html, value[0])
     assert_same_element(session, head, value[1])
-    assert_same_element(session, body, value[2])
-    assert_same_element(session, ps[0], value[3])
-    assert_same_element(session, ps[1], value[4])
+    assert_same_element(session, meta, value[2])
+    assert_same_element(session, body, value[3])
+    assert_same_element(session, ps[0], value[4])
+    assert_same_element(session, ps[1], value[5])
 
 
 def test_html_collection(session):
     session.url = inline("""
         <p>foo
         <p>bar
         """)
     ps = session.find.css("p")
--- a/testing/web-platform/tests/webdriver/tests/execute_script/collections.py
+++ b/testing/web-platform/tests/webdriver/tests/execute_script/collections.py
@@ -51,30 +51,32 @@ def test_file_list(session, tmpdir):
 
 def test_html_all_collection(session):
     session.url = inline("""
         <p>foo
         <p>bar
         """)
     html = session.find.css("html", all=False)
     head = session.find.css("head", all=False)
+    meta = session.find.css("meta", all=False)
     body = session.find.css("body", all=False)
     ps = session.find.css("p")
 
     response = execute_script(session, "return document.all")
     value = assert_success(response)
     assert isinstance(value, list)
-    # <html>, <head>, <body>, <p>, <p>
-    assert len(value) == 5
+    # <html>, <head>, <meta>, <body>, <p>, <p>
+    assert len(value) == 6
 
     assert_same_element(session, html, value[0])
     assert_same_element(session, head, value[1])
-    assert_same_element(session, body, value[2])
-    assert_same_element(session, ps[0], value[3])
-    assert_same_element(session, ps[1], value[4])
+    assert_same_element(session, meta, value[2])
+    assert_same_element(session, body, value[3])
+    assert_same_element(session, ps[0], value[4])
+    assert_same_element(session, ps[1], value[5])
 
 
 def test_html_collection(session):
     session.url = inline("""
         <p>foo
         <p>bar
         """)
     ps = session.find.css("p")
--- a/testing/web-platform/tests/webdriver/tests/support/inline.py
+++ b/testing/web-platform/tests/webdriver/tests/support/inline.py
@@ -1,54 +1,89 @@
+"""Helpers for inlining extracts of documents in tests."""
+
 import urllib
 
 
-def inline(doc,
-           doctype="html",
-           mime="text/html;charset=utf-8",
-           **kwargs):
-    from .fixtures import server_config, url
-    build_url = url(server_config())
-
-    if doctype == "html":
-        mime = "text/html;charset=utf-8"
-    elif doctype == "xhtml":
-        mime = "application/xhtml+xml"
-        doc = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+BOILERPLATES = {
+    "html": "<!doctype html>\n<meta charset={charset}>\n{src}",
+    "xhtml": """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
   <head>
     <title>XHTML might be the future</title>
   </head>
 
   <body>
-    {}
+    {src}
   </body>
-</html>""".format(doc)
-    elif doctype == "xml":
-        mime = "text/xml"
-        doc = """<?xml version="1.0" encoding="UTF-8"?>{}""".format(doc)
+</html>""",
+    "xml": """<?xml version="1.0" encoding="{charset}"?>\n{src}""",
+}
+MIME_TYPES = {
+    "html": "text/html",
+    "xhtml": "application/xhtml+xml",
+    "xml": "text/xml",
+}
+
+def inline(src, doctype="html", mime=None, charset=None, **kwargs):
+    """
+    Takes a source extract and produces well-formed documents.
+
+    Based on the desired document type, the extract is embedded with
+    predefined boilerplate in order to produce well-formed documents.
+    The media type and character set may also be individually configured.
 
-    query = {"doc": doc}
-    if mime != "text/html;charset=utf8":
-        query["content-type"] = mime
+    This helper function originally used data URLs, but since these
+    are not universally supported (or indeed standardised!) across
+    browsers, it now delegates the serving of the document to wptserve.
+    This file also acts as a wptserve handler (see the main function
+    below) which configures the HTTP response using query parameters.
+
+    This function returns a URL to the wptserve handler, which in turn
+    will serve an HTTP response with the requested source extract
+    inlined in a well-formed document, and the Content-Type header
+    optionally configured using the desired media type and character set.
 
-    return build_url("/webdriver/tests/support/inline.py",
-                     query=urllib.urlencode(query),
-                     **kwargs)
+    Any additional keyword arguments are passed on to the build_url
+    function.
+    """
+    from .fixtures import server_config, url
+    build_url = url(server_config())
+
+    if mime is None:
+        mime = MIME_TYPES[doctype]
+    if charset is None:
+        charset = "UTF-8"
+    doc = BOILERPLATES[doctype].format(charset=charset, src=src)
+
+    query = {"doc": doc, "mime": mime, "charset": charset}
+    return build_url(
+        "/webdriver/tests/support/inline.py",
+        query=urllib.urlencode(query),
+        **kwargs)
 
 
-def iframe(doc, **kwargs):
-    return "<iframe src='%s'></iframe>" % inline(doc, **kwargs)
+def iframe(src, **kwargs):
+    """Inlines document extract as the source document of an <iframe>."""
+    return "<iframe src='{}'></iframe>".format(inline(src, **kwargs))
 
 
 def main(request, response):
     doc = request.GET.first("doc", None)
-    content_type = request.GET.first("content-type", "text/html;charset=utf8")
+    mime = request.GET.first("mime", None)
+    charset = request.GET.first("charset", None)
+
     if doc is None:
-        rv = 404, [("Content-Type", "text/plain")], "Missing doc parameter in query"
-    else:
-        response.headers.update([
-            ("Content-Type", content_type),
-            ("X-XSS-Protection", "0")
-        ])
-        rv = doc
-    return rv
+        return 404, [("Content-Type",
+                      "text/plain")], "Missing doc parameter in query"
+
+    content_type = []
+    if mime is not None:
+        content_type.append(mime)
+    if charset is not None:
+        content_type.append("charset={}".format(charset))
+
+    headers = {"X-XSS-Protection": "0"}
+    if len(content_type) > 0:
+        headers["Content-Type"] = ";".join(content_type)
+
+    return 200, headers.items(), doc