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))"] |