forked from mirrors/gecko-dev
Bug 1793227, part 9 - Automated fixes for js/xpconnect/tests/browser/. r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D158508
This commit is contained in:
parent
1e9cfa44fc
commit
cbfad78f92
4 changed files with 43 additions and 23 deletions
|
|
@ -144,7 +144,6 @@ js/src/tests/
|
|||
js/src/Y.js
|
||||
|
||||
# Changes to XPConnect tests must be carefully audited.
|
||||
js/xpconnect/tests/browser/
|
||||
js/xpconnect/tests/mochitest/
|
||||
js/xpconnect/tests/unit/
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ add_task(async function test_browser_hang() {
|
|||
// Trip some testing code to ensure we can test this. Sadly, this is a magic
|
||||
// number corresponding to code in XPCJSContext.cpp
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["dom.max_chrome_script_run_time", 2]]
|
||||
set: [["dom.max_chrome_script_run_time", 2]],
|
||||
});
|
||||
await SpecialPowers.promiseTimeout(0);
|
||||
|
||||
|
|
@ -39,14 +39,22 @@ add_task(async function test_browser_hang() {
|
|||
);
|
||||
return events.parent?.some(e => e[1] == "slow_script_warning");
|
||||
}, "Should find an event after doing this.").catch(e => ok(false, e));
|
||||
events = (events.parent || []);
|
||||
events = events.parent || [];
|
||||
let event = events.find(e => e[1] == "slow_script_warning");
|
||||
ok(event, "Should have registered an event.");
|
||||
if (event) {
|
||||
is(event[3], "browser", "Should register as browser hang.");
|
||||
let args = event[5];
|
||||
is(args.uri_type, "browser", "Should register browser uri type.");
|
||||
Assert.greater(duration + 1, parseFloat(args.hang_duration), "hang duration should not exaggerate.");
|
||||
Assert.less(duration - 1, parseFloat(args.hang_duration), "hang duration should not undersell.");
|
||||
Assert.greater(
|
||||
duration + 1,
|
||||
parseFloat(args.hang_duration),
|
||||
"hang duration should not exaggerate."
|
||||
);
|
||||
Assert.less(
|
||||
duration - 1,
|
||||
parseFloat(args.hang_duration),
|
||||
"hang duration should not undersell."
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,28 +6,40 @@
|
|||
"use strict";
|
||||
|
||||
add_task(async function test_explicit_object_prototype() {
|
||||
const url = "http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_promise_userInteractionHandling.html";
|
||||
const url =
|
||||
"http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_promise_userInteractionHandling.html";
|
||||
await BrowserTestUtils.withNewTab(url, async browser => {
|
||||
await ContentTask.spawn(browser, {}, async () => {
|
||||
const { EventUtils } = ChromeUtils.import(
|
||||
"resource://specialpowers/SpecialPowersEventUtils.jsm"
|
||||
);
|
||||
const DOMWindowUtils = EventUtils._getDOMWindowUtils(content.window);
|
||||
is(DOMWindowUtils.isHandlingUserInput, false,
|
||||
"not yet handling user input");
|
||||
is(
|
||||
DOMWindowUtils.isHandlingUserInput,
|
||||
false,
|
||||
"not yet handling user input"
|
||||
);
|
||||
const button = content.document.getElementById("button");
|
||||
|
||||
let resolve;
|
||||
const p = new Promise(r => { resolve = r; });
|
||||
const p = new Promise(r => {
|
||||
resolve = r;
|
||||
});
|
||||
|
||||
button.addEventListener("click", () => {
|
||||
is(DOMWindowUtils.isHandlingUserInput, true, "handling user input");
|
||||
content.document.hasStorageAccess().then(() => {
|
||||
is(DOMWindowUtils.isHandlingUserInput, true,
|
||||
"still handling user input");
|
||||
is(
|
||||
DOMWindowUtils.isHandlingUserInput,
|
||||
true,
|
||||
"still handling user input"
|
||||
);
|
||||
Promise.resolve().then(() => {
|
||||
is(DOMWindowUtils.isHandlingUserInput, false,
|
||||
"no more handling user input");
|
||||
is(
|
||||
DOMWindowUtils.isHandlingUserInput,
|
||||
false,
|
||||
"no more handling user input"
|
||||
);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,22 +6,23 @@
|
|||
"use strict";
|
||||
|
||||
async function test_document(url) {
|
||||
await BrowserTestUtils.withNewTab(url, async function (browser) {
|
||||
let result = await ContentTask.spawn(
|
||||
browser, {},
|
||||
async function() {
|
||||
let result = content.document.getElementById("result");
|
||||
return result.innerText;
|
||||
}
|
||||
);
|
||||
await BrowserTestUtils.withNewTab(url, async function(browser) {
|
||||
let result = await ContentTask.spawn(browser, {}, async function() {
|
||||
let result = content.document.getElementById("result");
|
||||
return result.innerText;
|
||||
});
|
||||
is(result, "OK", "test succeeds");
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function test_explicit_object_prototype() {
|
||||
await test_document("http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_realm_key_object_prototype_top.html");
|
||||
await test_document(
|
||||
"http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_realm_key_object_prototype_top.html"
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_implicit_object_prototype() {
|
||||
await test_document("http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_realm_key_promise_top.html");
|
||||
await test_document(
|
||||
"http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_realm_key_promise_top.html"
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue