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

Unified Diff: chrome/content/tests/elemhide.js

Issue 29356338: Issue 4504 - Speed up element hiding integration tests (Closed) Base URL: https://hg.adblockplus.org/adblockplustests
Patch Set: Created Oct. 7, 2016, 11:25 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: chrome/content/tests/elemhide.js
===================================================================
--- a/chrome/content/tests/elemhide.js
+++ b/chrome/content/tests/elemhide.js
@@ -103,40 +103,34 @@
[["###test1", "~localhost#@##test1"], ["hidden", "visible"]],
[["###test1", "#@##test1"], ["visible", "visible"]],
[["localhost###test1", "#@##test1"], ["visible", "visible"]],
[["localhost.###test1"], ["visible", "visible"]],
[["localhost.,localhost###test1"], ["hidden", "visible"]],
[["localhost.,foo.###test1"], ["visible", "visible"]],
- [["##div#test1", "@@localhost$generichide"], ["visible", "visible"]],
- [["##div#test1", "@@localhost$genericblock"], ["hidden", "visible"]],
- [["localhost##div#test1", "@@localhost$generichide"], ["hidden", "visible"]],
- [["~example.com##div#test1", "@@localhost$generichide"], ["visible", "visible"]],
- [["~example.com##div#test1", "@@localhost$genericblock"], ["hidden", "visible"]],
- [["~example.com,localhost##div#test1", "@@localhost$generichide"], ["hidden", "visible"]],
+ [["###test1", "localhost###test2", "@@||localhost^$document"], ["visible", "visible"]],
+ [["###test1", "localhost###test2", "@@||localhost^$~document"], ["hidden", "hidden"]],
+ [["###test1", "localhost###test2", "@@||localhost^$elemhide"], ["visible", "visible"]],
+ [["###test1", "localhost###test2", "@@||localhost^$~elemhide"], ["hidden", "hidden"]],
+
+ [["###test1", "@@||localhost^$generichide"], ["visible", "visible"]],
+ [["###test1", "@@||localhost^$genericblock"], ["hidden", "visible"]],
+ [["localhost###test1", "@@||localhost^$generichide"], ["hidden", "visible"]],
+ [["~example.com###test1", "@@||localhost^$generichide"], ["visible", "visible"]],
+ [["~example.com###test1", "@@||localhost^$genericblock"], ["hidden", "visible"]],
+ [["~example.com,localhost###test1", "@@||localhost^$generichide"], ["hidden", "visible"]],
];
- function runTest([filters, expected], stage)
+ function runTest(filters, expected)
{
for (let filterText of filters)
FilterStorage.addFilter(Filter.fromText(filterText));
- if (stage == 2)
- FilterStorage.addFilter(Filter.fromText("@@||localhost^$document"));
- else if (stage == 3)
- FilterStorage.addFilter(Filter.fromText("@@||localhost^$~document"));
- else if (stage == 4)
- FilterStorage.addFilter(Filter.fromText("@@||localhost^$elemhide"));
-
- // Second and forth runs are whitelisted, nothing should be hidden
- if (stage == 2 || stage == 4)
- expected = ["visible", "visible"];
-
frame.addEventListener("abp:frameready", function()
{
let frameScript = `
// The "load" event doesn't mean that our styles are applied - these
// are only applied after a message roundtrip to parent determining
// whether element hiding is enabled. Do the same roundtrip here before
// checking visibility to make sure timing is right.
addMessageListener("pong", function()
@@ -158,22 +152,11 @@
start();
});
frame.messageManager.loadFrameScript("data:text/javascript," + encodeURIComponent(frameScript), false);
}, false, true);
frame.setAttribute("src", "http://localhost:1234/test");
}
- let stageDescriptions = {
- 1: "running without exceptions",
- 2: "running with whitelisted document",
- 3: "running with exception not applying to documents",
- 4: "running with element hiding exception",
- };
-
- for (let test = 0; test < tests.length; test++)
- {
- let [filters, expected] = tests[test];
- for (let stage = 1; stage in stageDescriptions; stage++)
- asyncTest(filters.join(", ") + " (" + stageDescriptions[stage] + ")", runTest.bind(null, tests[test], stage));
- }
+ for (let [filters, expected] of tests)
+ asyncTest(filters.join(", "), runTest.bind(null, filters, expected));
})();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld