Bug 1819120 - [bidi] Migrate test_RemoteValue.js to a browser mochitest r=webdriver-reviewers,whimboo

Depends on D170809
Migrate the test to a browser mochitest and start testing deserialization in WindowRealm

Differential Revision: https://phabricator.services.mozilla.com/D171107
This commit is contained in:
Julian Descottes 2023-02-28 13:24:18 +00:00
parent c9738d3a71
commit 621bd2b0a3
4 changed files with 41 additions and 1 deletions

View File

@ -7,4 +7,8 @@ JAR_MANIFESTS += ["jar.mn"]
with Files("**"):
BUG_COMPONENT = ("Remote Protocol", "WebDriver BiDi")
BROWSER_CHROME_MANIFESTS += [
"test/browser/browser.ini",
]
XPCSHELL_TESTS_MANIFESTS += ["test/xpcshell/xpcshell.ini"]

View File

@ -0,0 +1,5 @@
[DEFAULT]
tags = remote
subsuite = remote
[browser_RemoteValue.js]

View File

@ -418,6 +418,20 @@ add_task(function test_deserializeLocalValues() {
}
});
add_task(async function test_deserializeLocalValuesInWindowRealm() {
for (const type of REMOTE_SIMPLE_VALUES.concat(REMOTE_COMPLEX_VALUES)) {
const { value: expectedValue, serialized, deserializable } = type;
// Skip non deserializable cases
if (!deserializable) {
continue;
}
const value = await deserializeInWindowRealm(serialized);
assertLocalValue(serialized.type, value, expectedValue);
}
});
add_task(function test_deserializeLocalValuesByHandle() {
// Create two realms, realm1 will be used to serialize values, while realm2
// will be used as a reference empty realm without any object reference.
@ -986,3 +1000,21 @@ function assertInternalIds(serializationInternalMap, amount) {
"Got expected amount of internalIds in serializationInternalMap"
);
}
function deserializeInWindowRealm(serialized) {
return SpecialPowers.spawn(
gBrowser.selectedBrowser,
[serialized],
async _serialized => {
const { WindowRealm } = ChromeUtils.importESModule(
"chrome://remote/content/webdriver-bidi/Realm.sys.mjs"
);
const { deserialize } = ChromeUtils.importESModule(
"chrome://remote/content/webdriver-bidi/RemoteValue.sys.mjs"
);
const realm = new WindowRealm(content);
info(`Checking '${_serialized.type}'`);
return deserialize(realm, _serialized);
}
);
}

View File

@ -3,5 +3,4 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
[test_Realm.js]
[test_RemoteValue.js]
[test_WebDriverBiDiConnection.js]