Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions common/subset-tests-by-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
var collectCounts = false;
var keys = {};
var exclude = false;
var idlMemberPattern = null;
var excludeMember = false;
if (location.search) {
match = /(?:^\?|&)(include|exclude)=([^&]+)?/.exec(location.search);
if (match) {
Expand All @@ -13,6 +15,11 @@
exclude = true;
}
}
let matchIDL = /(?:^\?|&)(includeMember|excludeMember)=([^&]+)?/.exec(location.search);
if (matchIDL && subTestKeyPattern && !exclude) {
idlMemberPattern = new RegExp(`^${matchIDL[2]}$`);
excludeMember = matchIDL[1] === 'excludeMember';
}
// Below is utility code to generate <meta> for copy/paste into tests.
// Sample usage:
// test.html?get-keys
Expand Down Expand Up @@ -43,11 +50,23 @@
}
}
/**
* Check if `key` is in the subset specified in the URL.
* Check if the test should be excluded according to the
* arguments specified in the URL.
* @param {string} key
* @param {string} idlMemberName
* @returns {boolean}
*/
function shouldRunSubTest(key, idlMemberName) {
return checkByKey(key) && checkIDLMemberName(idlMemberName)
}

/**
* Checks if the test key should be excluded, according
* to the include= or exclude= query parameters in the URL.
* @param {string} key
* @returns {boolean}
*/
function shouldRunSubTest(key) {
function checkByKey(key) {
if (key && subTestKeyPattern) {
var found = subTestKeyPattern.test(key);
if (exclude) {
Expand All @@ -57,6 +76,23 @@
}
return true;
}
/**
* Checks if the idl member should be excluded, according to the
* includeMember= or excludeMember= URL parameters.
* @param {string} idlMemberName
* @returns {boolean}
*/
function checkIDLMemberName(idlMemberName) {
if (!idlMemberPattern) {
return true;
}
if (!idlMemberName) {
return excludeMember
}
var found = idlMemberPattern.test(idlMemberName);
return found != excludeMember;
}

/**
* Only test a subset of tests with `?include=Foo` or `?exclude=Foo` in the URL.
* Can be used together with `<meta name="variant" content="...">`
Expand All @@ -73,7 +109,7 @@
keys[key] = 1;
}
}
if (shouldRunSubTest(key)) {
if (checkByKey(key)) {
return testFunc(...args);
}
return null;
Expand Down
4 changes: 4 additions & 0 deletions event-timing/idlharness.any.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// META: variant=?include=PerformanceEventTiming&excludeMember=targetSelector
// META: variant=?include=PerformanceEventTiming&includeMember=targetSelector
// META: variant=?exclude=PerformanceEventTiming
// META: global=window,worker
// META: script=/common/subset-tests-by-key.js
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js

Expand Down
4 changes: 4 additions & 0 deletions event-timing/idlharness.window.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// META: variant=?include=PerformanceEventTiming&excludeMember=targetSelector
// META: variant=?include=PerformanceEventTiming&includeMember=targetSelector
// META: variant=?exclude=PerformanceEventTiming
// META: global=window
// META: script=/common/subset-tests-by-key.js
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js

Expand Down
8 changes: 4 additions & 4 deletions resources/idlharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -2163,7 +2163,7 @@ IdlInterface.prototype.test_member_const = function(member)

IdlInterface.prototype.test_member_attribute = function(member)
{
if (!shouldRunSubTest(this.name)) {
if (!shouldRunSubTest(this.name, member.name)) {
return;
}
var a_test = subsetTestByKey(this.name, async_test, this.name + " interface: attribute " + member.name);
Expand Down Expand Up @@ -2256,7 +2256,7 @@ IdlInterface.prototype.test_member_attribute = function(member)

IdlInterface.prototype.test_member_operation = function(member)
{
if (!shouldRunSubTest(this.name)) {
if (!shouldRunSubTest(this.name, member.name)) {
return;
}
var a_test = subsetTestByKey(this.name, async_test, this.name + " interface: operation " + member);
Expand Down Expand Up @@ -3351,7 +3351,7 @@ IdlNamespace.prototype.do_member_operation_asserts = function (memberHolderObjec

IdlNamespace.prototype.test_member_operation = function(member)
{
if (!shouldRunSubTest(this.name)) {
if (!shouldRunSubTest(this.name, member.name)) {
return;
}
var a_test = subsetTestByKey(
Expand All @@ -3370,7 +3370,7 @@ IdlNamespace.prototype.test_member_operation = function(member)

IdlNamespace.prototype.test_member_attribute = function (member)
{
if (!shouldRunSubTest(this.name)) {
if (!shouldRunSubTest(this.name, member.name)) {
return;
}
var a_test = subsetTestByKey(
Expand Down
Loading