Skip to content
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

Enable WPT tests for the Generic Sensor classes #10198

Merged
merged 1 commit into from
May 8, 2018

Conversation

chromium-wpt-export-bot
Copy link
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Mar 27, 2018

This patch introduces mock implementations of the Sensor
and SensorProvider mojo interfaces to the WPT tests
for Chromium.

The ongoing WPT issue for the Generic Sensor tests automation:
#9686

Bug: 816462
Change-Id: I8e4880ee5269b07f0bf68a2752038e128d166c55
Reviewed-on: https://chromium-review.googlesource.com/980886
Reviewed-by: Mike West [email protected]
Reviewed-by: Philip Jägenstedt [email protected]
Reviewed-by: Reilly Grant [email protected]
Reviewed-by: Alexander Shalamov [email protected]
Commit-Queue: Mikhail Pozdnyakov [email protected]
Cr-Commit-Position: refs/heads/master@{#550586}


This change is Reviewable

Copy link
Collaborator

@wpt-pr-bot wpt-pr-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already reviewed downstream.

@ghost
Copy link

ghost commented Mar 27, 2018

Build PASSED

Started: 2018-04-04 09:23:25
Finished: 2018-04-04 09:57:00

View more information about this build on:

@Honry
Copy link
Contributor

Honry commented Mar 28, 2018

@pozdnyakov, thank you for bring this to advance test automation for Generic Sensor.
One concern, why we don't use WebDriver based automation solution? As it is more popular in WPT.

And if we use Test API, we should definitely defined a Test API spec for both test contributor and future implementations. Just like what WebUSB had done at https://wicg.github.io/webusb/test/

};
}, name, properties);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd better to wrap above codes into a separated JS file specific for different implementation backends, and defined common util functions for generic-sensor-tests.js

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll put it into a separate '.. -helper.js' file in the next patch at https://chromium-review.googlesource.com/c/chromium/src/+/980886

@@ -120,7 +169,7 @@ function runGenericSensorTests(sensorType) {
sensor.stop();
}, `${sensorType.name}: sensor.start() returns undefined`);

promise_test(async t => {
sensor_test(async t => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually many tests can be automated without Test API. We should only replace those tests really need Test API for automation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, so I've modified only those test cases that need actual sensor backend working


test(() => {
const invalidFreqs = [
"invalid",
NaN,
Infinity,
-Infinity,
{},
undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the undefined value?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, unlike the following test case for referenceFrame, the frequency field does not have a default value, so undefined should be returned here. Thanks for the catch!

};
}, name, properties);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll put it into a separate '.. -helper.js' file in the next patch at https://chromium-review.googlesource.com/c/chromium/src/+/980886

@@ -120,7 +169,7 @@ function runGenericSensorTests(sensorType) {
sensor.stop();
}, `${sensorType.name}: sensor.start() returns undefined`);

promise_test(async t => {
sensor_test(async t => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, so I've modified only those test cases that need actual sensor backend working


test(() => {
const invalidFreqs = [
"invalid",
NaN,
Infinity,
-Infinity,
{},
undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, unlike the following test case for referenceFrame, the frequency field does not have a default value, so undefined should be returned here. Thanks for the catch!

@@ -300,8 +350,7 @@ function runGenericSensorTests(sensorType) {
123,
{},
"",
true,
undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here undefined is valid input as referenceFrame has a default value (based on https://heycam.github.io/webidl/#es-dictionary)

@pozdnyakov
Copy link
Contributor

@Honry thanks for your comments! Could we proceed the review process in https://chromium-review.googlesource.com/c/chromium/src/+/980886, so that we have all the comments consolidated in a single place.

@pozdnyakov, thank you for bring this to advance test automation for Generic Sensor.
One concern, why we don't use WebDriver based automation solution? As it is more popular in WPT.

For the Generic Sensor implementation in Chromium we want to test the whole bindings code in the dedicated module, this could be achieved only with mocking the involved mojo interfaces. Not sure WebDriver can do this.

And if we use Test API, we should definitely defined a Test API spec for both test contributor and future implementations. Just like what WebUSB had done at https://wicg.github.io/webusb/test/

So far it's only initialize and reset methods.. Unless the test API becomes more complex, I'd not create a new specification for it.

@Honry
Copy link
Contributor

Honry commented Mar 30, 2018

@Honry thanks for your comments! Could we proceed the review process in https://chromium-review.googlesource.com/c/chromium/src/+/980886, so that we have all the comments consolidated in a single place.

@pozdnyakov, sorry for the inconvenient, I will review in chromium for your next patch.

So far it's only initialize and reset methods.. Unless the test API becomes more complex, I'd not create a new specification for it.

So, will you bring more methods to WPT?

@foolip
Copy link
Member

foolip commented Apr 13, 2018

@pozdnyakov, Travis is failing because when running these tests against Chrome Dev, the results were unstable. From https://travis-ci.org/w3c/web-platform-tests/jobs/366060782, can you tell why that is the case instead of them all failing consistently due to the lack of mojo mocking? We shouldn't change this PR unless we really have to, if there's some fix needed then a separate Chromium CL that we export roughly at the same time is better.

@jgraham FYI that this introduces something that's special for Chrome and will only work with extra command line arguments, the same as for Bluetooth and USB: --enable-blink-features=MojoJS,MojoJSTest

Because this doesn't expose any new API surface but just makes it seem like sensors exist it's not very hard to see a WebDriver path forward for this, and #9686 is the tracking issue.

@Honry
Copy link
Contributor

Honry commented Apr 17, 2018

I ran these tests locally, got the same error, MojoInterfaceInterceptor is not defined.

Error appears upon starting the browser that “you are using an unsupported command line flag: --enable-blink-features=MojoJS,MojoTest. Stability and security will suffer”

@foolip
Copy link
Member

foolip commented Apr 17, 2018

@Honry how about if you pass the flags as documented in http://web-platform-tests.org/running-tests/chrome.html?

@Honry
Copy link
Contributor

Honry commented Apr 18, 2018

Yeah, it works, but another consistent error: ReferenceError: testRunner is not defined,
root cause: the testRunner at line 204 from resources/chromium/generic_sensor_mocks.js is undefined.

Moreover, @pozdnyakov, tests under following folders should be updated as well, because they are using the same framework: generic-sensor-tests.js, I can do this once this PR is merged.

  • ambient-light
  • geolocation-sensor
  • proximity

@foolip
Copy link
Member

foolip commented Apr 18, 2018

Ah, if (testRunner) needs to be if (window.testRunner). Can you see if that fixes the problem? If so can you make the change in Chromium? Then I'll merge this and the other change will be exported automatically.

@Honry
Copy link
Contributor

Honry commented Apr 19, 2018

@foolip, yes, window.testRunner can fix the problem, actually testRunner.setPermission only works in Chromium testRunner, we can skip it in WPT testing since at present the permission of sensors is enabled via "GenericSensor" and "GenericSensorExtraClasses" flags.

But there coming with another consistent error :-/
Mock sensor initialization fails at following code snippet,
generic-sensor-mocks.js

124 +        this.binding_.setConnectionErrorHandler(() => {
125 +          console.error("Mojo connection error");
126 +          this.reset();
127 +        });

While which can be pass in Chromium Layout testing (test path: LayoutTests/external/wpt/), @pozdnyakov, could you pls. take a look?

@foolip
Copy link
Member

foolip commented Apr 19, 2018

That's probably because of web-platform-tests/results-collection#81, right?

@Honry
Copy link
Contributor

Honry commented Apr 20, 2018

No, I've already passed the Mojo flags, --enable-blink-features=MojoJS,MojoJSTest, and tested WebUSB tests which can succeed to create an mock USB.

@foolip
Copy link
Member

foolip commented Apr 21, 2018

Oh. Well then I have no idea, hopefully @pozdnyakov does :)

@pozdnyakov
Copy link
Contributor

Looking.. Sorry for the delay

@foolip
Copy link
Member

foolip commented Apr 26, 2018

@pozdnyakov any luck? Should we merge this and look into the fix separately, or what's the most effective way to resolve this?

@foolip
Copy link
Member

foolip commented Apr 27, 2018

Just to see if the flakiness has gone away, as in #10497, I'll rebase this to trigger another Travis run.

@rakuco
Copy link
Member

rakuco commented Apr 30, 2018

cc @alexshalamov

@kereliuk
Copy link
Contributor

kereliuk commented May 2, 2018

restarts travis

@pozdnyakov
Copy link
Contributor

@foolip sorry for the late notice. I'm not working on the project starting from this month. Unfortunately I was not able to fix the flakiness before I left. I think someone from my team can proceed with this. @alexshalamov could you PTAL?

@foolip
Copy link
Member

foolip commented May 8, 2018

@alexshalamov will you be able to look at this? Note that after about a month the Chromium-side CL will fall outside of the window of considered commits and the change will be implicitly reverted by import. And... it turns out this happened 5 days ago:
https://chromium.googlesource.com/chromium/src/+/9bb566abdfddab2e5acda5e1525be9c8e343a7cc

That's really unfortunate, because these were good changes. I think the cleanest thing to recover is to just merge this now. @Hexcles, do you know how we could notice when this is approaching to raise the urgency of a blocked export when it gets close?

@foolip foolip force-pushed the chromium-export-cl-980886 branch from 56e189a to 350abc0 Compare May 8, 2018 11:32
@foolip
Copy link
Member

foolip commented May 8, 2018

I've rebased the branch (chromium-export-cl-980886) on master. When Travis has finished running, if the only Travis failures are in the Chrome stability job, I will merge this PR and file a bug to track the flakiness.

This patch introduces mock implementations of the Sensor
and SensorProvider mojo interfaces to the WPT tests
for Chromium.

The ongoing WPT issue for the Generic Sensor tests automation:
#9686

Bug: 816462
Change-Id: I8e4880ee5269b07f0bf68a2752038e128d166c55
Reviewed-on: https://chromium-review.googlesource.com/980886
Reviewed-by: Mike West <[email protected]>
Reviewed-by: Philip Jägenstedt <[email protected]>
Reviewed-by: Reilly Grant <[email protected]>
Reviewed-by: Alexander Shalamov <[email protected]>
Commit-Queue: Mikhail Pozdnyakov <[email protected]>
Cr-Commit-Position: refs/heads/master@{#550586}
@foolip foolip force-pushed the chromium-export-cl-980886 branch from c0488d9 to 395be6a Compare May 8, 2018 20:49
@foolip foolip merged commit b55a93a into master May 8, 2018
@foolip foolip deleted the chromium-export-cl-980886 branch May 8, 2018 21:30
@foolip
Copy link
Member

foolip commented May 8, 2018

Merged with this failure:
https://travis-ci.org/w3c/web-platform-tests/jobs/376549386

It's possible and even likely that some of these tests will now be flaky in Chrome Dev, so I'll file another issue for that.

@Hexcles
Copy link
Member

Hexcles commented May 8, 2018

@foolip thanks for putting out the fire.

The window used to be around a month, and only few un-merged exports have been overwritten by imports so far. Yet apparently the window can bu much shorter in reality (see https://crbug.com/752214), and when overwriting does happen, things can be messy and confusing. I'll increase the history window for now to give us a longer window to handle unmerged exports for now, and think about a long-term solution for this "ultimate" failure mode of the exporter.

Honry added a commit to Honry/web-platform-tests that referenced this pull request May 11, 2018
 - `if (testRunner)` should be `if (window.testRunner)`
 - Use String to pass sensor object param to avoid undefined error
foolip pushed a commit that referenced this pull request Jun 14, 2018
 - `if (testRunner)` should be `if (window.testRunner)`
 - Use String to pass sensor object param to avoid undefined error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants