Backed out changeset d24535fc8fc5 (bug 1775064) for causing mochitest failures on browser_all_files_referenced.js . CLOSED TREE

This commit is contained in:
criss 2022-06-21 20:47:12 +03:00
Родитель 4da0c6a7f8
Коммит de373eee8c
8 изменённых файлов: 47 добавлений и 143 удалений

Просмотреть файл

@ -13,15 +13,15 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox id="things">
<checkbox id="testBox" label="box" />
<input xmlns="http://www.w3.org/1999/xhtml" id="textInput" size="6" value="test" label="input" />
<input xmlns="http://www.w3.org/1999/xhtml" id="textInput2" size="6" value="test" label="input" />
<input xmlns="http://www.w3.org/1999/xhtml" id="textInput3" class="asdf" size="6" value="test" label="input" />
<checkbox id="testBox" label="box" />
</vbox>
<iframe id="iframe" name="iframename" src="chrome://remote/content/marionette/test2.xhtml"/>
<iframe id="iframe" name="iframename" src="chrome://remote/content/marionette/test_nested_iframe.xhtml"/>
<hbox id="testXulBox"/>
<browser id="aBrowser" src="chrome://remote/content/marionette/test2.xhtml"/>
<browser id='aBrowser' src="chrome://remote/content/marionette/test2.xhtml"/>
</dialog>
</window>

Просмотреть файл

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!-- Test file for a non XUL window by using a XHTML document instead. -->
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<html id="winTest"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title Test</title>
</head>
<body xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<vbox id="things">
<input xmlns="http://www.w3.org/1999/xhtml" id="textInput" size="6" value="test" label="input" />
<input xmlns="http://www.w3.org/1999/xhtml" id="textInput2" size="6" value="test" label="input" />
<input xmlns="http://www.w3.org/1999/xhtml" id="textInput3" class="asdf" size="6" value="test" label="input" />
<input type="checkbox" id="testBox" label="box" />
</vbox>
<html:iframe id="iframe" name="iframename" src="chrome://remote/content/marionette/test2.xhtml" />
<html:iframe id="iframe" name="iframename" src="chrome://remote/content/marionette/test_nested_iframe.xhtml" />
</body>
</html>

Просмотреть файл

@ -1359,17 +1359,22 @@ element.isXULElement = function(node) {
};
/**
* Ascertains whether <var>node</var> is in a privileged document.
* Ascertains whether <var>node</var> is in a XUL document.
*
* @param {*} node
* Node to check.
* Element to check
*
* @return {boolean}
* True if <var>node</var> is in a privileged document,
* True if <var>node</var> is in a XUL document,
* false otherwise.
*/
element.isInPrivilegedDocument = function(node) {
return !!node?.nodePrincipal?.isSystemPrincipal;
element.isInXULDocument = function(node) {
return (
typeof node == "object" &&
node !== null &&
"ownerDocument" in node &&
node.ownerDocument.documentElement.namespaceURI === XUL_NS
);
};
/**
@ -1506,14 +1511,14 @@ class WebElement {
static from(node) {
const uuid = WebElement.generateUUID();
if (element.isShadowRoot(node) && !element.isInPrivilegedDocument(node)) {
if (element.isShadowRoot(node) && !element.isInXULDocument(node)) {
// When we support Chrome Shadowroots we will need to
// do a check here of shadowroot.host being in a privileged document
// do a check here of shadowroot.host being a XUL document
// See Bug 1743541
return new ContentShadowRoot(uuid);
} else if (element.isElement(node)) {
if (element.isInPrivilegedDocument(node)) {
// If the node is in a priviledged document, we are in "chrome" context.
if (element.isInXULDocument(node)) {
// If the node is in a XUL document, we are in "chrome" context.
return new ChromeWebElement(uuid);
}
return new ContentWebElement(uuid);

Просмотреть файл

@ -41,14 +41,13 @@ remote.jar:
content/marionette/sync.js (sync.js)
content/marionette/transport.js (transport.js)
#ifdef ENABLE_TESTS
content/marionette/test.xhtml (chrome/test.xhtml)
content/marionette/test2.xhtml (chrome/test2.xhtml)
content/marionette/test_dialog.dtd (chrome/test_dialog.dtd)
content/marionette/test_dialog.properties (chrome/test_dialog.properties)
content/marionette/test_dialog.xhtml (chrome/test_dialog.xhtml)
content/marionette/test_menupopup.xhtml (chrome/test_menupopup.xhtml)
content/marionette/test_nested_iframe.xhtml (chrome/test_nested_iframe.xhtml)
content/marionette/test_no_xul.xhtml (chrome/test_no_xul.xhtml)
content/marionette/test.xhtml (chrome/test.xhtml)
content/marionette/test2.xhtml (chrome/test2.xhtml)
#ifdef MOZ_CODE_COVERAGE
content/marionette/PerTestCoverageUtils.jsm (../../tools/code-coverage/PerTestCoverageUtils.jsm)
#endif

Просмотреть файл

@ -103,13 +103,11 @@ class XULElement extends Element {
const domEl = new DOMElement("p");
const svgEl = new SVGElement("rect");
const xulEl = new XULElement("text");
const domElInPrivilegedDocument = new Element("input", {
nodePrincipal: { isSystemPrincipal: true },
});
const xulElInPrivilegedDocument = new XULElement("text", {
nodePrincipal: { isSystemPrincipal: true },
const xulEl = new XULElement("browser");
const domElInXULDocument = new DOMElement("input", {
ownerDocument: {
documentElement: { namespaceURI: XUL_NS },
},
});
class WindowProxy {
@ -185,10 +183,9 @@ add_test(function test_isElement() {
add_test(function test_isDOMElement() {
ok(element.isDOMElement(domEl));
ok(element.isDOMElement(domElInPrivilegedDocument));
ok(element.isDOMElement(domElInXULDocument));
ok(element.isDOMElement(svgEl));
ok(!element.isDOMElement(xulEl));
ok(!element.isDOMElement(xulElInPrivilegedDocument));
ok(!element.isDOMElement(domWin));
ok(!element.isDOMElement(domFrame));
for (let typ of [true, 42, {}, [], undefined, null]) {
@ -200,12 +197,11 @@ add_test(function test_isDOMElement() {
add_test(function test_isXULElement() {
ok(element.isXULElement(xulEl));
ok(element.isXULElement(xulElInPrivilegedDocument));
ok(!element.isXULElement(domElInPrivilegedDocument));
ok(!element.isXULElement(domElInXULDocument));
ok(!element.isXULElement(domEl));
ok(!element.isXULElement(svgEl));
ok(!element.isXULElement(domWin));
ok(!element.isXULElement(domFrame));
ok(!element.isDOMElement(domWin));
ok(!element.isDOMElement(domFrame));
for (let typ of [true, 42, {}, [], undefined, null]) {
ok(!element.isXULElement(typ));
}
@ -217,7 +213,7 @@ add_test(function test_isDOMWindow() {
ok(element.isDOMWindow(domWin));
ok(element.isDOMWindow(domFrame));
ok(!element.isDOMWindow(domEl));
ok(!element.isDOMWindow(domElInPrivilegedDocument));
ok(!element.isDOMWindow(domElInXULDocument));
ok(!element.isDOMWindow(svgEl));
ok(!element.isDOMWindow(xulEl));
for (let typ of [true, 42, {}, [], undefined, null]) {
@ -435,11 +431,10 @@ add_test(function test_WebElemenet_is() {
add_test(function test_WebElement_from() {
ok(WebElement.from(domEl) instanceof ContentWebElement);
ok(WebElement.from(xulEl) instanceof ContentWebElement);
ok(WebElement.from(domWin) instanceof ContentWebWindow);
ok(WebElement.from(domFrame) instanceof ContentWebFrame);
ok(WebElement.from(domElInPrivilegedDocument) instanceof ChromeWebElement);
ok(WebElement.from(xulElInPrivilegedDocument) instanceof ChromeWebElement);
ok(WebElement.from(xulEl) instanceof ChromeWebElement);
ok(WebElement.from(domElInXULDocument) instanceof ChromeWebElement);
Assert.throws(() => WebElement.from({}), /InvalidArgumentError/);

Просмотреть файл

@ -16,7 +16,7 @@ class TestElementSizeChrome(WindowManagerMixin, MarionetteTestCase):
self.marionette.set_context("chrome")
new_window = self.open_chrome_window(
"chrome://remote/content/marionette/test.xhtml"
"chrome://remote/content/marionette/test2.xhtml"
)
self.marionette.switch_to_window(new_window)

Просмотреть файл

@ -6,13 +6,9 @@ from __future__ import absolute_import
from marionette_driver.by import By
from marionette_driver.errors import NoSuchElementException
from marionette_driver.marionette import CHROME_ELEMENT_KEY, HTMLElement
from marionette_driver.marionette import HTMLElement
from marionette_harness import MarionetteTestCase, parameterized, WindowManagerMixin
PAGE_XHTML = "chrome://remote/content/marionette/test_no_xul.xhtml"
PAGE_XUL = "chrome://remote/content/marionette/test.xhtml"
from marionette_harness import MarionetteTestCase, WindowManagerMixin
class TestElementsChrome(WindowManagerMixin, MarionetteTestCase):
@ -21,112 +17,69 @@ class TestElementsChrome(WindowManagerMixin, MarionetteTestCase):
self.marionette.set_context("chrome")
win = self.open_chrome_window("chrome://remote/content/marionette/test.xhtml")
self.marionette.switch_to_window(win)
def tearDown(self):
self.close_all_windows()
super(TestElementsChrome, self).tearDown()
@parameterized("XUL", PAGE_XUL)
@parameterized("XHTML", PAGE_XHTML)
def test_id(self, chrome_url):
win = self.open_chrome_window(chrome_url)
self.marionette.switch_to_window(win)
def test_id(self):
el = self.marionette.execute_script(
"return window.document.getElementById('textInput');"
)
found_el = self.marionette.find_element(By.ID, "textInput")
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(CHROME_ELEMENT_KEY, found_el.kind)
self.assertEqual(el, found_el)
@parameterized("XUL", PAGE_XUL)
@parameterized("XHTML", PAGE_XHTML)
def test_that_we_can_find_elements_from_css_selectors(self, chrome_url):
win = self.open_chrome_window(chrome_url)
self.marionette.switch_to_window(win)
def test_that_we_can_find_elements_from_css_selectors(self):
el = self.marionette.execute_script(
"return window.document.getElementById('textInput');"
)
found_el = self.marionette.find_element(By.CSS_SELECTOR, "#textInput")
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(CHROME_ELEMENT_KEY, found_el.kind)
self.assertEqual(el, found_el)
@parameterized("XUL", PAGE_XUL)
@parameterized("XHTML", PAGE_XHTML)
def test_child_element(self, chrome_url):
win = self.open_chrome_window(chrome_url)
self.marionette.switch_to_window(win)
def test_child_element(self):
el = self.marionette.find_element(By.ID, "textInput")
parent = self.marionette.find_element(By.ID, "things")
found_el = parent.find_element(By.TAG_NAME, "input")
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(CHROME_ELEMENT_KEY, found_el.kind)
self.assertEqual(el, found_el)
@parameterized("XUL", PAGE_XUL)
@parameterized("XHTML", PAGE_XHTML)
def test_child_elements(self, chrome_url):
win = self.open_chrome_window(chrome_url)
self.marionette.switch_to_window(win)
def test_child_elements(self):
el = self.marionette.find_element(By.ID, "textInput3")
parent = self.marionette.find_element(By.ID, "things")
found_els = parent.find_elements(By.TAG_NAME, "input")
self.assertTrue(el.id in [found_el.id for found_el in found_els])
@parameterized("XUL", PAGE_XUL)
@parameterized("XHTML", PAGE_XHTML)
def test_tag_name(self, chrome_url):
win = self.open_chrome_window(chrome_url)
self.marionette.switch_to_window(win)
def test_tag_name(self):
el = self.marionette.execute_script(
"return window.document.getElementsByTagName('vbox')[0];"
)
found_el = self.marionette.find_element(By.TAG_NAME, "vbox")
self.assertEqual("vbox", found_el.tag_name)
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(CHROME_ELEMENT_KEY, found_el.kind)
self.assertEqual(el, found_el)
@parameterized("XUL", PAGE_XUL)
@parameterized("XHTML", PAGE_XHTML)
def test_class_name(self, chrome_url):
win = self.open_chrome_window(chrome_url)
self.marionette.switch_to_window(win)
def test_class_name(self):
el = self.marionette.execute_script(
"return window.document.getElementsByClassName('asdf')[0];"
)
found_el = self.marionette.find_element(By.CLASS_NAME, "asdf")
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(CHROME_ELEMENT_KEY, found_el.kind)
self.assertEqual(el, found_el)
@parameterized("XUL", PAGE_XUL)
@parameterized("XHTML", PAGE_XHTML)
def test_xpath(self, chrome_url):
win = self.open_chrome_window(chrome_url)
self.marionette.switch_to_window(win)
def test_xpath(self):
el = self.marionette.execute_script(
"return window.document.getElementById('testBox');"
)
found_el = self.marionette.find_element(By.XPATH, "id('testBox')")
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(CHROME_ELEMENT_KEY, found_el.kind)
self.assertEqual(el, found_el)
@parameterized("XUL", PAGE_XUL)
@parameterized("XHTML", PAGE_XHTML)
def test_not_found(self, chrome_url):
win = self.open_chrome_window(chrome_url)
self.marionette.switch_to_window(win)
def test_not_found(self):
self.marionette.timeout.implicit = 1
self.assertRaises(
NoSuchElementException,
@ -142,12 +95,7 @@ class TestElementsChrome(WindowManagerMixin, MarionetteTestCase):
"I'm not on the page",
)
@parameterized("XUL", PAGE_XUL)
@parameterized("XHTML", PAGE_XHTML)
def test_timeout(self, chrome_url):
win = self.open_chrome_window(chrome_url)
self.marionette.switch_to_window(win)
def test_timeout(self):
self.assertRaises(
NoSuchElementException, self.marionette.find_element, By.ID, "myid"
)
@ -160,10 +108,7 @@ class TestElementsChrome(WindowManagerMixin, MarionetteTestCase):
document.getElementById('things').appendChild(b);
}, 1000); """
)
found_el = self.marionette.find_element(By.ID, "myid")
self.assertEqual(HTMLElement, type(found_el))
self.assertEqual(CHROME_ELEMENT_KEY, found_el.kind)
self.assertEqual(HTMLElement, type(self.marionette.find_element(By.ID, "myid")))
self.marionette.execute_script(
"""
var elem = window.document.getElementById('things');

Просмотреть файл

@ -18,16 +18,7 @@ class TestTitleChrome(WindowManagerMixin, MarionetteTestCase):
super(TestTitleChrome, self).tearDown()
def test_get_title_xhtml(self):
win = self.open_chrome_window(
"chrome://remote/content/marionette/test_no_xul.xhtml"
)
self.marionette.switch_to_window(win)
expected_title = self.marionette.execute_script("return window.document.title;")
self.assertEqual(self.marionette.title, expected_title)
def test_get_title_xul(self):
def test_get_chrome_title(self):
win = self.open_chrome_window("chrome://remote/content/marionette/test.xhtml")
self.marionette.switch_to_window(win)