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

Make bindings aware of exposed members/partial interfaces #23500

Merged
merged 1 commit into from Jul 14, 2019

Conversation

@sreeise
Copy link
Contributor

sreeise commented Jun 3, 2019


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #23332
  • There are tests for these changes OR
  • These changes do not require tests because ___

This change is Reviewable

@highfive
Copy link

highfive commented Jun 3, 2019

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @avadacatavra (or someone else) soon.

@highfive
Copy link

highfive commented Jun 3, 2019

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/bindings/codegen/CodegenRust.py, components/script/dom/bindings/guard.rs
  • @KiChjang: components/script/dom/bindings/codegen/CodegenRust.py, components/script/dom/bindings/guard.rs
@highfive
Copy link

highfive commented Jun 3, 2019

warning Warning warning

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

jdm commented Jun 3, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented Jun 3, 2019

Trying commit 47e3db6 with merge 3a639e3...

bors-servo added a commit that referenced this pull request Jun 3, 2019
Make bindings aware of exposed members/partial interfaces

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

---
<!-- 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
- [ ] These changes fix #23332

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23500)
<!-- Reviewable:end -->
return "Condition::Satisfied"


def ExposedCondition(cond):

This comment has been minimized.

@sreeise

sreeise Jun 3, 2019

Author Contributor

This function is just temporary. I wans't sure if there was a better way to get the mappings for the global bit sets. Also, what do 'Worklet' and 'Worker' map to? There is no obvious global bit set for those versus something like 'ServiceWorker'

This comment has been minimized.

@jdm

jdm Jun 3, 2019

Member

Worklet and Worker map to any interface that has a [Global=(Worker)] or [Global=(Worklet)] annotation, respectively. For example, both ServiceWorkerGlobalScope and DedicatedWorkerGlobalScope should match Worker.

@@ -2593,6 +2621,12 @@ def definition_body(self):
assert isinstance(func, list) and len(func) == 1
conditions.append("%s(aCx, aObj)" % func[0])

exposed = iface.getExtendedAttribute("Exposed")

This comment has been minimized.

@sreeise

sreeise Jun 3, 2019

Author Contributor

@jdm Looking at the generated bindings the constructors for some of the interfaces are duplicated. PerformanceBinding.rs shows:

unsafe fn ConstructorEnabled(aCx: *mut JSContext, aObj: HandleObject) -> bool {
    is_exposed_in(aObj, InterfaceObjectMap::Globals::DEDICATED_WORKER_GLOBAL_SCOPE | InterfaceObjectMap::Globals::SERVICE_WORKER_GLOBAL_SCOPE | InterfaceObjectMap::Globals::WINDOW) &&
    is_exposed_in(aObj, InterfaceObjectMap::Globals::DEDICATED_WORKER_GLOBAL_SCOPE | InterfaceObjectMap::Globals::WINDOW)
} 

These include both the iface.exposureSet and the Exposed attribute which seems to be why they are duplicated.
I am not sure on this, should one of these be changed or left out?

This comment has been minimized.

@jdm

jdm Jun 3, 2019

Member

What if we merge the exposureSet and exposed attribute checks by creating a set made of the values and iterating over them? Something like set(camel_to_upper_snake(i) for i in iface.exposureSet) + set(camel_to_upper_snake(i) for i in exposed), then generate a single is_exposed_in from the resulting set?

This comment has been minimized.

@jdm

jdm Jun 3, 2019

Member

Possibly we should be taking the intersection of the sets, rather than the union of them.

This comment has been minimized.

@sreeise

sreeise Jun 4, 2019

Author Contributor

After looking at both the exposed list and iface.exposureSet, there is actually no difference between the two so there may not be a need to generate anything for the exposed list here. The naming is different where the exposed list only includes 'worker' and 'worklet' instead of the global names for worker and worklet but once you map them to the correct names they are the same as the exposureSet for every interface.

@sreeise
Copy link
Contributor Author

sreeise commented Jun 3, 2019

The changes don't expose all of the annotations. I was facing some issues when there are multiple annotations exposed versus just one. If I change MemberCondition to return a list of exposed attributes when there are multiple annotations then I could possibly change generateGuardedArray to check for a list and append each condition in the prefableSpecs list:


Unfortunately, when I attempted to do so it caused either GL errors or crash errors from Pipeline.rs. I am not exactly sure at this point what is causing the errors or if there is another way to go about this.

@bors-servo
Copy link
Contributor

bors-servo commented Jun 3, 2019

💔 Test failed - linux-rel-css

Copy link
Member

jdm left a comment

Good start!

return "Condition::Satisfied"


def ExposedCondition(cond):

This comment has been minimized.

@jdm

jdm Jun 3, 2019

Member

Worklet and Worker map to any interface that has a [Global=(Worker)] or [Global=(Worklet)] annotation, respectively. For example, both ServiceWorkerGlobalScope and DedicatedWorkerGlobalScope should match Worker.

"DedicatedWorker": "DedicatedWorkerGlobalScope",
"PaintWorklet": "PaintWorkletGlobalScope",
"TestWorklet": "TestWorkletGlobalScope"
})

This comment has been minimized.

@jdm

jdm Jun 3, 2019

Member

We should be able to generate this dictionary programmatically:

  • global_descriptors = config.getDescriptors(isGlobal=True) gives us all of the interfaces that have a Global annotation
  • descriptor.interface.getExtendedAttribute("Global") gives us the list of values for a particular interface
@@ -1565,7 +1591,9 @@ def getControllingCondition(interfaceMember, descriptor):
PropertyDefiner.getStringAttr(interfaceMember,
"Pref"),
PropertyDefiner.getStringAttr(interfaceMember,
"Func"))
"Func"),
PropertyDefiner.getStringAttr(interfaceMember,

This comment has been minimized.

@jdm

jdm Jun 3, 2019

Member

I suspect that we will want a different method than getStringAttr because Exposed can contain multiple values?

@@ -2593,6 +2621,12 @@ def definition_body(self):
assert isinstance(func, list) and len(func) == 1
conditions.append("%s(aCx, aObj)" % func[0])

exposed = iface.getExtendedAttribute("Exposed")

This comment has been minimized.

@jdm

jdm Jun 3, 2019

Member

What if we merge the exposureSet and exposed attribute checks by creating a set made of the values and iterating over them? Something like set(camel_to_upper_snake(i) for i in iface.exposureSet) + set(camel_to_upper_snake(i) for i in exposed), then generate a single is_exposed_in from the resulting set?

@jdm
Copy link
Member

jdm commented Jun 3, 2019

I would be really interested in learning more about the errors you saw when you changed generateGuardedArray.

@jdm jdm assigned jdm and unassigned avadacatavra Jun 3, 2019
@jdm
Copy link
Member

jdm commented Jun 3, 2019

The current test failures don't look good:

  │ called `Result::unwrap()` on an `Err` value: () (thread ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(1) }, at src/libcore/result.rs:999)
  │ stack backtrace:
  │    0:     0x55829411289d - backtrace::backtrace::trace::hebbee589b71fa4b4
  │    1:     0x558294111702 - <backtrace::capture::Backtrace as core::default::Default>::default::hefd0ac5d542e2f26
  │    2:     0x55829104d24f - servo::main::{{closure}}::h46466e6e3dca0931
  │    3:     0x5582942f2c98 - rust_panic_with_hook
  │                         at src/libstd/panicking.rs:478
  │    4:     0x5582942f2731 - continue_panic_fmt
  │                         at src/libstd/panicking.rs:381
  │    5:     0x5582942f2615 - rust_begin_unwind
  │    6:     0x5582943115dc - panic_fmt
  │                         at src/libcore/panicking.rs:85
  │    7:     0x558291f2848a - core::result::unwrap_failed::h68c616a3589a1d60
  │    8:     0x5582922f99f6 - _ZN6script3dom8bindings5guard9Condition12is_satisfied17h5112ef86b15e156bE.llvm.2759114191324085468
  │    9:     0x55829208b8fd - script::dom::bindings::interface::create_object::h347e1a14dc508d68
  │   10:     0x55829208b009 - script::dom::bindings::interface::create_interface_prototype_object::ha1fc74c00cf7c8ce
@jdm
Copy link
Member

jdm commented Jun 3, 2019

Ok, the failures are coming from passing the prototype objects to is_exposed_in (ie. the objects being created by create_interface_prototype_object in CreateInterfaceObjects), which are created with a basic JSClass instead of a JSClass that is part of a DOMJSClass.

I think we can solve this by changing the create_object function to accept a new global: HandleObject argument, pass that to the define_guarded_[methods|properties|constants] functions, and passing the global object when calling is_exposed_in.

@sreeise sreeise force-pushed the sreeise:exposed_binding_gen branch from 47e3db6 to bc42087 Jun 4, 2019
@sreeise
Copy link
Contributor Author

sreeise commented Jun 4, 2019

Ok, the failures are coming from passing the prototype objects to is_exposed_in (ie. the objects being created by create_interface_prototype_object in CreateInterfaceObjects), which are created with a basic JSClass instead of a JSClass that is part of a DOMJSClass.

I think we can solve this by changing the create_object function to accept a new global: HandleObject argument, pass that to the define_guarded_[methods|properties|constants] functions, and passing the global object when calling is_exposed_in.

I am honestly not sure if this is fixed or not (I guess we will see). Running the tests in a debugger, at least for me, is crashing my screen with out of memory errors so I am assuming this still needs some work.

@sreeise
Copy link
Contributor Author

sreeise commented Jun 4, 2019

I would be really interested in learning more about the errors you saw when you changed generateGuardedArray.

They were 502 GL errors and 0 for the pipeline namespace id, but these are no longer there after I made the changes you suggested for create_object and related methods. I believe the errors were related to the same issues in the test failure. If it happens again ill get the back trace to show here.

@jdm
Copy link
Member

jdm commented Jun 4, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented Jun 4, 2019

Trying commit bc42087 with merge 2e8306c...

bors-servo added a commit that referenced this pull request Jun 4, 2019
Make bindings aware of exposed members/partial interfaces

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

---
<!-- 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
- [ ] These changes fix #23332

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23500)
<!-- Reviewable:end -->
@jdm
Copy link
Member

jdm commented Jul 14, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented Jul 14, 2019

Trying commit f0cb6af with merge 90ed027...

bors-servo added a commit that referenced this pull request Jul 14, 2019
Make bindings aware of exposed members/partial interfaces

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

---
<!-- 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
- [ ] These changes fix #23332

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23500)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 14, 2019

💔 Test failed - linux-rel-wpt

@@ -9,7 +9,9 @@
client.addEventListener("readystatechange", test.step_func(function() {
if(client.readyState == 4) {
control_flag = true
assert_equals(client.responseXML, null)
if (test.GLOBAL.isWindow()) {

This comment has been minimized.

@CYBAI

CYBAI Jul 14, 2019

Collaborator

I think you can fix the failure by using self.GLOBAL.isWindow() 👀

Ref: https://web-platform-tests.org/writing-tests/testharness.html#multi-global-tests

This comment has been minimized.

@sreeise

sreeise Jul 14, 2019

Author Contributor

Oh ok, I was thinking it was referring to the actual name used for the test object.

@CYBAI
Copy link
Collaborator

CYBAI commented Jul 14, 2019

{
    "status": "PASS", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": "WorkerNavigator interface: member productSub", 
    "test": "/html/dom/interfaces.worker.html", 
    "line": 295183, 
    "action": "test_result", 
    "expected": "FAIL"
}
{
    "status": "PASS", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": "WorkerNavigator interface: member vendor", 
    "test": "/html/dom/interfaces.worker.html", 
    "line": 295185, 
    "action": "test_result", 
    "expected": "FAIL"
}
{
    "status": "PASS", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": "WorkerNavigator interface: member vendorSub", 
    "test": "/html/dom/interfaces.worker.html", 
    "line": 295186, 
    "action": "test_result", 
    "expected": "FAIL"
}
{
    "status": "PASS", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": "WorkerNavigator interface: self.navigator must not have property \"productSub\"", 
    "test": "/html/dom/interfaces.worker.html", 
    "line": 295200, 
    "action": "test_result", 
    "expected": "FAIL"
}
{
    "status": "PASS", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": "WorkerNavigator interface: self.navigator must not have property \"vendor\"", 
    "test": "/html/dom/interfaces.worker.html", 
    "line": 295202, 
    "action": "test_result", 
    "expected": "FAIL"
}
{
    "status": "PASS", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": "WorkerNavigator interface: self.navigator must not have property \"vendorSub\"", 
    "test": "/html/dom/interfaces.worker.html", 
    "line": 295203, 
    "action": "test_result", 
    "expected": "FAIL"
}
{
    "status": "FAIL", 
    "group": "default", 
    "message": "test.GLOBAL is undefined", 
    "stack": "@http://web-platform.test:8000/xhr/abort-after-send.any.js:12:17\nTest.prototype.step@http://web-platform.test:8000/resources/testharness.js:1611:25\nTest.prototype.step_func/<@http://web-platform.test:8000/resources/testharness.js:1635:35\n@http://web-platform.test:8000/xhr/abort-after-send.any.js:24:16\nTest.prototype.step@http://web-platform.test:8000/resources/testharness.js:1611:25\n@http://web-platform.test:8000/xhr/abort-after-send.any.js:5:12\n@http://web-platform.test:8000/xhr/abort-after-send.any.worker.js:9:1\n", 
    "subtest": "XMLHttpRequest: abort() after send()", 
    "test": "/xhr/abort-after-send.any.worker.html", 
    "line": 326120, 
    "action": "test_result", 
    "expected": "PASS"
}
@sreeise
Copy link
Contributor Author

sreeise commented Jul 14, 2019

html/dom has an .ini file for WorkerNavigator I didnt see but I am not sure why abort-after-send.any.js is saying that test.GLOBAL is undefined.

…s/partial interfaces
@sreeise sreeise force-pushed the sreeise:exposed_binding_gen branch from f0cb6af to 871239a Jul 14, 2019
@servo-wpt-sync
Copy link
Collaborator

servo-wpt-sync commented Jul 14, 2019

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at web-platform-tests/wpt#17812.

@sreeise
Copy link
Contributor Author

sreeise commented Jul 14, 2019

Hopefully that is all of them. Sorry about causing the tests to have to be rerun. I am getting a segfault crash if I try to run abort-after-send.any.js locally which also happens on a few other tests so I can't be sure if it actually passes.

@jdm
Copy link
Member

jdm commented Jul 14, 2019

Could you file a separate issue with the backtrace from the segfault when running that test? That sounds interesting.

@jdm
Copy link
Member

jdm commented Jul 14, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented Jul 14, 2019

Trying commit 871239a with merge 43fb4dd...

bors-servo added a commit that referenced this pull request Jul 14, 2019
Make bindings aware of exposed members/partial interfaces

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

---
<!-- 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
- [ ] These changes fix #23332

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23500)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 14, 2019

☀️ Test successful - linux-rel-css, linux-rel-wpt, status-taskcluster
State: approved= try=True

@jdm
Copy link
Member

jdm commented Jul 14, 2019

@bors-servo r+
Thanks for all the work to fix this long-standing problem!

@bors-servo
Copy link
Contributor

bors-servo commented Jul 14, 2019

📌 Commit 871239a has been approved by jdm

@sreeise
Copy link
Contributor Author

sreeise commented Jul 14, 2019

Could you file a separate issue with the backtrace from the segfault when running that test? That sounds interesting.

Done! #23772

@bors-servo
Copy link
Contributor

bors-servo commented Jul 14, 2019

Testing commit 871239a with merge 95b304b...

bors-servo added a commit that referenced this pull request Jul 14, 2019
Make bindings aware of exposed members/partial interfaces

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

---
<!-- 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
- [ ] These changes fix #23332

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23500)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 14, 2019

☀️ Test successful - linux-rel-css, linux-rel-wpt, status-taskcluster
Approved by: jdm
Pushing 95b304b to master...

@bors-servo bors-servo merged commit 871239a into servo:master Jul 14, 2019
3 checks passed
3 checks passed
Taskcluster (pull_request) TaskGroup: success
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Jul 14, 2019
2 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

7 participants
You can’t perform that action at this time.