Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/browser/elemHideEmulation.js

Issue 29984555: Issue 6959 - Use async/await in test/browser/elemHideEmulation.js (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Jan. 17, 2019, 6:34 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/browser/elemHideEmulation.js
===================================================================
--- a/test/browser/elemHideEmulation.js
+++ b/test/browser/elemHideEmulation.js
@@ -143,59 +143,80 @@
function createElementWithStyle(styleBlock, parent)
{
let element = createElement(parent);
insertStyleRule("#" + element.id + " " + styleBlock);
return element;
}
// Create a new ElemHideEmulation instance with @selectors.
-function applyElemHideEmulation(selectors)
+async function applyElemHideEmulation(selectors, test)
{
- return Promise.resolve().then(() =>
+ await Promise.resolve();
Manish Jethani 2019/01/17 08:03:33 This should not be necessary but I left it in for
+
+ let elemHideEmulation = null;
+
+ try
{
- let elemHideEmulation = new ElemHideEmulation(
+ elemHideEmulation = new ElemHideEmulation(
elems =>
{
for (let elem of elems)
elem.style.display = "none";
}
);
elemHideEmulation.document = testDocument;
elemHideEmulation.MIN_INVOCATION_INTERVAL = REFRESH_INTERVAL / 2;
elemHideEmulation.apply(selectors.map(
selector => ({selector, text: selector})
));
- return elemHideEmulation;
- });
+ }
+ catch (error)
+ {
+ if (!test)
Manish Jethani 2019/01/17 08:03:33 This should not be necessary if every call to this
Manish Jethani 2019/01/17 08:04:36 Removed now.
+ throw error;
+
+ unexpectedError.call(test, error);
+ return null;
+ }
+
+ return elemHideEmulation;
}
-exports.testVerbatimPropertySelector = function(test)
+exports.testVerbatimPropertySelector = async function(test)
{
let toHide = createElementWithStyle("{background-color: #000}");
- applyElemHideEmulation(
- [":-abp-properties(background-color: rgb(0, 0, 0))"]
- ).then(() =>
+
+ if (await applyElemHideEmulation(
+ [":-abp-properties(background-color: rgb(0, 0, 0))"],
+ test
+ ))
{
expectHidden(test, toHide);
- }).catch(unexpectedError.bind(test)).then(() => test.done());
+ }
+
+ test.done();
};
-exports.testVerbatimPropertySelectorWithPrefix = function(test)
+exports.testVerbatimPropertySelectorWithPrefix = async function(test)
{
let parent = createElementWithStyle("{background-color: #000}");
let toHide = createElementWithStyle("{background-color: #000}", parent);
- applyElemHideEmulation(
- ["div > :-abp-properties(background-color: rgb(0, 0, 0))"]
- ).then(() =>
+
+ if (await applyElemHideEmulation(
+ ["div > :-abp-properties(background-color: rgb(0, 0, 0))"],
+ test
+ ))
{
expectVisible(test, parent);
expectHidden(test, toHide);
- }).catch(unexpectedError.bind(test)).then(() => test.done());
+ }
+
+ test.done();
};
exports.testVerbatimPropertySelectorWithPrefixNoMatch = function(test)
{
let parent = createElementWithStyle("{background-color: #000}");
let toHide = createElementWithStyle("{background-color: #fff}", parent);
applyElemHideEmulation(
["div > :-abp-properties(background-color: rgb(0, 0, 0))"]
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld