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

Pipeline lookup in webdriver #11791

Merged
merged 1 commit into from Jul 26, 2016
Merged

Conversation

@craftytrickster
Copy link
Contributor

craftytrickster commented Jun 19, 2016

Fixes #11712

Removed a method that seemed to duplicate already existing functionality, and returned BrowsingContextErrors in the web_handler file where panics were previously occurring.

I am not sure if I like all the unwrapping that occurs in the script thread, but the current methods are not set up to return Option/Result.

Also, should line the method on line 37 find_node_by_unique_id of components/script/webdriver_handlers.rs return None if the context is not found like I have it currently? Or should it return a Result<Option...> instead?

  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #11712 .
  • There are tests for these changes OR
  • These changes do not require tests because I simply removed a method that duplicated already existing functionality. On the other part, I added better error sending instead of forcing a panic, which does not require testing to my knowledge.

This change is Reviewable

@highfive

This comment has been minimized.

Copy link

highfive commented Jun 19, 2016

Heads up! This PR modifies the following files:

  • @asajeffrey: components/webdriver_server/lib.rs
  • @jgraham: components/webdriver_server/lib.rs
  • @KiChjang: components/script/script_thread.rs, components/script/devtools.rs, components/script/webdriver_handlers.rs
@highfive

This comment has been minimized.

Copy link

highfive commented Jun 19, 2016

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@cbrewster

This comment has been minimized.

Copy link
Member

cbrewster commented Jun 19, 2016

This does have some overlap with #11695.

@craftytrickster

This comment has been minimized.

Copy link
Contributor Author

craftytrickster commented Jun 19, 2016

Maybe I should rebase my changes over those ones, replacing my script thread file with the one from that PR. @asajeffrey do you agree?

@craftytrickster craftytrickster force-pushed the craftytrickster:11712/pipeline-lookup branch 2 times, most recently from ec8ffde to 534f492 Jun 19, 2016
@asajeffrey

This comment has been minimized.

Copy link
Member

asajeffrey commented Jun 20, 2016

Sorry about the delay, Mozilla has been off in London last week!

It might be worth rebasing once #11695 has landed. There is some overlap between this PR and it.

Alternatively, we could have this PR leave get_browsing_context alone, and I'll rebase #11695 once this one lands.

@craftytrickster

This comment has been minimized.

Copy link
Contributor Author

craftytrickster commented Jun 20, 2016

No worries, whatever you prefer.

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented Jun 24, 2016

☔️ The latest upstream changes (presumably #11695) made this pull request unmergeable. Please resolve the merge conflicts.

@asajeffrey asajeffrey self-assigned this Jul 14, 2016
@jdm

This comment has been minimized.

Copy link
Member

jdm commented Jul 14, 2016

@craftytrickster Could you rebase this, now that #11695 has merged?

@jdm jdm removed their assignment Jul 14, 2016
@asajeffrey

This comment has been minimized.

Copy link
Member

asajeffrey commented Jul 14, 2016

Reviewed the changes, mostly this much better, thanks! The only thing that's worth looking at is the remaining panics in devtools.rs. It would be nice to replace those with warnings.


Reviewed 2 of 3 files at r4, 3 of 3 files at r5.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

@craftytrickster craftytrickster force-pushed the craftytrickster:11712/pipeline-lookup branch from 534f492 to d438c75 Jul 14, 2016
@craftytrickster

This comment has been minimized.

Copy link
Contributor Author

craftytrickster commented Jul 14, 2016

Rebasing now, I will take a look at the comments and address them after.

@craftytrickster

This comment has been minimized.

Copy link
Contributor Author

craftytrickster commented Jul 15, 2016

@asajeffrey I removed the unwraps, but I am not sure if the way I did it is preferable, is returning early and not panicking really a better solution? Should these methods maybe return a Result type?

let context = context.find(pipeline).unwrap();
let context = match context.find(pipeline) {
Some(found_context) => found_context,
None => return warn!("No root node found for pipeline id {}", pipeline)

This comment has been minimized.

Copy link
@izgzhen

izgzhen Jul 15, 2016

Contributor

@craftytrickster Maybe you can make reply a IpcSender<Result<NodeInfo, SomeErrorType>>? (I am not an expert on that, but it looks like no other places are using this message now so I think it is safe to change its type)

@Manishearth Manishearth changed the title 11712/pipeline lookup Pipeline lookup in webdriver Jul 15, 2016
@@ -91,17 +98,12 @@ fn find_node_by_unique_id(context: &BrowsingContext,
pipeline: PipelineId,

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jul 15, 2016

Member

Can we return Results everywhere instead of panicking?

@Manishearth

This comment has been minimized.

Copy link
Member

Manishearth commented Jul 15, 2016

Everything should be returning a Result, which bubble up until the error can be sent down a channel.

@craftytrickster

This comment has been minimized.

Copy link
Contributor Author

craftytrickster commented Jul 15, 2016

@Manishearth do you mean actually return a Result from the function, or do you mean what @izgzhen is saying?

@Manishearth

This comment has been minimized.

Copy link
Member

Manishearth commented Jul 15, 2016

Functions which do not send anything down a sender should use Result in their return type. Functions which do, should use Result in the sender, like you do here

@craftytrickster

This comment has been minimized.

Copy link
Contributor Author

craftytrickster commented Jul 15, 2016

Thanks for the clarification. When I have time after work I will make the changes.

@asajeffrey

This comment has been minimized.

Copy link
Member

asajeffrey commented Jul 15, 2016

We now have warnings included in issue reports, so whether or not we return a Result is about whether there's sensible error recovery we can do. If there is an error recovery action (e.g. returning an error via a webdriver or devtools channel) then returning a Result makes sense. If we're just going to include a warning if there's a subsequent error, then a warn! makes more sense.

@craftytrickster craftytrickster force-pushed the craftytrickster:11712/pipeline-lookup branch from fc257cc to 329a3fe Jul 16, 2016
@asajeffrey

This comment has been minimized.

Copy link
Member

asajeffrey commented Jul 18, 2016

A nit about linebreaking style, otherwise lgtm. Squash and then r=me.


Reviewed 1 of 3 files at r7, 2 of 3 files at r8, 4 of 4 files at r10.
Review status: all files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


components/script/devtools.rs, line 73 [r9] (raw file):

Previously, izgzhen (Zhen Zhang) wrote…

@craftytrickster Maybe you can make reply a IpcSender<Result<NodeInfo, SomeErrorType>>? (I am not an expert on that, but it looks like no other places are using this message now so I think it is safe to change its type)

Using `Option` for lookups which may miss seems fine to me.

components/webdriver_server/lib.rs, line 744 [r10] (raw file):

            Err(WebDriverJSError::BrowsingContextNotFound) => Err(WebDriverError::new(
                ErrorStatus::JavascriptError, "Pipeline id not found in browsing context"
            ))

Nit: linebreaking style.


Comments from Reviewable

@craftytrickster

This comment has been minimized.

Copy link
Contributor Author

craftytrickster commented Jul 25, 2016

@asajeffrey should I keep your initial commit and just squash my commits, or should I just squash them all?

@asajeffrey

This comment has been minimized.

Copy link
Member

asajeffrey commented Jul 25, 2016

Squash everything.

@craftytrickster craftytrickster force-pushed the craftytrickster:11712/pipeline-lookup branch from 3a6d2f9 to f31ce88 Jul 26, 2016
@craftytrickster

This comment has been minimized.

Copy link
Contributor Author

craftytrickster commented Jul 26, 2016

r=asajeffrey

@KiChjang

This comment has been minimized.

Copy link
Member

KiChjang commented Jul 26, 2016

@craftytrickster Sorry, bors-servo only listens to reviewers.

@bors-servo r=asajeffrey

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented Jul 26, 2016

📌 Commit f31ce88 has been approved by asajeffrey

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented Jul 26, 2016

⌛️ Testing commit f31ce88 with merge 983c30d...

bors-servo added a commit that referenced this pull request Jul 26, 2016
…ffrey

Pipeline lookup in webdriver

Fixes #11712

<!-- Please describe your changes on the following line: -->

Removed a method that seemed to duplicate already existing functionality, and returned BrowsingContextErrors in the web_handler file where panics were previously occurring.

I am not sure if I like all the unwrapping that occurs in the script thread, but the current methods are not set up to return Option/Result.

Also, should line the method on line 37 `find_node_by_unique_id` of components/script/webdriver_handlers.rs return None if the context is not found like I have it currently? Or should it return a `Result<Option...>` instead?

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #11712 .

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because I simply removed a method that duplicated already existing functionality. On the other part, I added better error sending instead of forcing a panic, which does not require testing to my knowledge.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11791)
<!-- Reviewable:end -->
@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented Jul 26, 2016

💔 Test failed - linux-dev

@jdm

This comment has been minimized.

Copy link
Member

jdm commented Jul 26, 2016

./components/script/devtools.rs:263: found an empty line following a {
./components/script/devtools.rs:279: found an empty line following a {
…Option values instead to indicate when a pipeline context is missing where appropriate. Additionally, removed erroneous method get_browsing_context.
@craftytrickster craftytrickster force-pushed the craftytrickster:11712/pipeline-lookup branch from f31ce88 to 2475dc1 Jul 26, 2016
@craftytrickster

This comment has been minimized.

Copy link
Contributor Author

craftytrickster commented Jul 26, 2016

Sorry about that, the tidy check has been fixed now.

@KiChjang

This comment has been minimized.

Copy link
Member

KiChjang commented Jul 26, 2016

@bors-servo r=asajeffrey

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented Jul 26, 2016

📌 Commit 2475dc1 has been approved by asajeffrey

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented Jul 26, 2016

⌛️ Testing commit 2475dc1 with merge a94b92f...

bors-servo added a commit that referenced this pull request Jul 26, 2016
…ffrey

Pipeline lookup in webdriver

Fixes #11712

<!-- Please describe your changes on the following line: -->

Removed a method that seemed to duplicate already existing functionality, and returned BrowsingContextErrors in the web_handler file where panics were previously occurring.

I am not sure if I like all the unwrapping that occurs in the script thread, but the current methods are not set up to return Option/Result.

Also, should line the method on line 37 `find_node_by_unique_id` of components/script/webdriver_handlers.rs return None if the context is not found like I have it currently? Or should it return a `Result<Option...>` instead?

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #11712 .

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because I simply removed a method that duplicated already existing functionality. On the other part, I added better error sending instead of forcing a panic, which does not require testing to my knowledge.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11791)
<!-- Reviewable:end -->
@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented Jul 26, 2016

@bors-servo bors-servo merged commit 2475dc1 into servo:master Jul 26, 2016
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.