-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dummy of test_driver #14
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool, thank you! Some work to do still.
.gitignore
Outdated
@@ -1,3 +1,17 @@ | |||
/node_modules/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert these changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reverted .gitignore, but /test/tests/resources
is added.
lib/wpt-runner.js
Outdated
if (!window.document.contains(element)) { | ||
return Promise.reject(new Error("element in different document or shadow tree")); | ||
} | ||
return new Promise(function(resolve) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Promise.resolve()
. Or, maybe actually implement it?
Same for all other very-long promise creations in this code.
lib/wpt-runner.js
Outdated
|
||
function getDummyCodeOfTestDriver() { | ||
return ` | ||
(function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This IIFE isn't needed.
lib/wpt-runner.js
Outdated
return ` | ||
(function() { | ||
window.test_driver = { | ||
bless: function(intent, action) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use bless(intent, action) {
.
"copy-testharness": "copyfiles -u 2 wpt/resources/testharness.js testharness/" | ||
"prepare": "npm run copy-testharness && npm run copy-resources", | ||
"copy-testharness": "copyfiles -u 2 wpt/resources/testharness.js testharness/", | ||
"copy-resources": "copyfiles -u 2 wpt/resources/testharness.js test/tests/resources/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't needed for preparing the published package, so it seems like this should be a pretest hook, not part of prepare.
test/runner.js
Outdated
const wptRunner = require(".."); | ||
|
||
const testcases = require("./testcases.json"); | ||
const filter = testPath => (testcases[testPath] === true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather just enumerate all the files in the test/tests directory using the fs APIs; then we don't need to manually update a testcases.json file.
test/tests/testdriver.html
Outdated
|
||
promise_test(async t => { | ||
await test_driver.send_keys(window.document.body); | ||
assert_true(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These assert_true
s do nothing, so they're best removed.
test/tests/testharness.html
Outdated
}, "test"); | ||
|
||
promise_test(t => { | ||
return Promise.resolve(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing a function to Promise.resolve() just resolves the promise with that function. Probably you should just not pass anything.
lib/wpt-runner.js
Outdated
@@ -208,3 +218,43 @@ function recursiveReaddir(dirPath) { | |||
}); | |||
}); | |||
} | |||
|
|||
function getDummyCodeOfTestDriver() { | |||
return ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it'd be better to move this to its own file, and fs.readFileSync it at the top of wpt-runner.js.
@domenic Thanks for your reviewing. I've modified what you pointed out. |
@sttk I made some further simplifications and fixes; please take a look and let me know what you think! |
@domenic Oh, I misread your comment as not to create I think it's also good, and I'm sorry that I forgot to lint. |
@domenic Thank you for merging! |
There are some tests in wpt, which use
test_driver
and cause error on wpt-runner.This pr sets dummy code of
test_driver
to response when a test html uses/resources/testdriver.js
.