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

fix(engine): adding more tests for proxies #407

Merged
merged 3 commits into from
Jun 13, 2018
Merged

Conversation

caridy
Copy link
Contributor

@caridy caridy commented Jun 13, 2018

@diervo these tests are supposed to cover a lot of ground in terms of potential illegal invocations. It will be interesting to see which line triggers that problem in core.

Does this PR introduce a breaking change?

  • No

const elm = createElement('x-foo', { is: MyComponent });
document.body.appendChild(elm);
const root = getHostShadowRoot(elm);
root.querySelector('div').innerHTML = 'something';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davidturissini @diervo in theory this should be fine since we don't have a setter trap for the proxy, which means the proxy will attempt to do the set into the original proxy target.

Since we only proxy nodes and methods of nodes, and no API that I know of has a setter that expects a node, we should be fine. Eventually we can add a set trap that unwrap the value before assigning it into the original target, but I could not find a DOM api that exemplify this potential problem.

const root = getHostShadowRoot(elm);
const div = root.querySelector('div');
const p = root.querySelector('p');
expect(div.contains(p)).toBe(true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is testing that when invoking methods, we do the proper unwrap before calling the underlaying method with the right context.

@caridy caridy requested a review from davidturissini June 13, 2018 03:50
@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 65ffad0 | Target commit: 6e4d5ac

lwc-engine-benchmark

table-append-1k metric base(65ffad0) target(6e4d5ac) trend
benchmark-table/append/1k duration 144.35 (± 5.70 ms) 143.40 (± 4.40 ms) 0.66% 👌
table-clear-1k metric base(65ffad0) target(6e4d5ac) trend
benchmark-table/clear/1k duration 11.30 (± 0.40 ms) 11.20 (± 0.45 ms) 0.88% 👌
table-create-10k metric base(65ffad0) target(6e4d5ac) trend
benchmark-table/create/10k duration 833.60 (± 2.90 ms) 836.00 (± 4.00 ms) -0.29% 👎
table-create-1k metric base(65ffad0) target(6e4d5ac) trend
benchmark-table/create/1k duration 101.10 (± 2.35 ms) 99.60 (± 2.60 ms) 1.48% 👌
table-update-10th-1k metric base(65ffad0) target(6e4d5ac) trend
benchmark-table/update-10th/1k duration 85.70 (± 5.80 ms) 86.10 (± 6.00 ms) -0.47% 👌
tablecmp-append-1k metric base(65ffad0) target(6e4d5ac) trend
benchmark-table-component/append/1k duration 240.10 (± 3.70 ms) 243.20 (± 3.00 ms) -1.29% 👌
tablecmp-clear-1k metric base(65ffad0) target(6e4d5ac) trend
benchmark-table/clear/1k duration 35.50 (± 1.40 ms) 35.00 (± 1.20 ms) 1.41% 👌
tablecmp-create-10k metric base(65ffad0) target(6e4d5ac) trend
benchmark-table-component/create/10k duration 1685.50 (± 9.80 ms) 1682.80 (± 8.10 ms) 0.16% 👌
tablecmp-create-1k metric base(65ffad0) target(6e4d5ac) trend
benchmark-table-component/create/1k duration 192.90 (± 4.30 ms) 194.70 (± 4.70 ms) -0.93% 👌
tablecmp-update-10th-1k metric base(65ffad0) target(6e4d5ac) trend
benchmark-table-component/update-10th/1k duration 74.00 (± 5.00 ms) 75.50 (± 3.60 ms) -2.03% 👌

return html;
}
renderedCallback() {
this.template.querySelector('span').innerHTML = '<i>something</i>';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davidturissini @diervo in theory this should be fine since we don't have a setter trap for the proxy, which means the proxy will attempt to do the set into the original proxy target.

Since we only proxy nodes and methods of nodes, and no API that I know of has a setter that expects a node, we should be fine. Eventually we can add a set trap that unwrap the value before assigning it into the original target, but I could not find a DOM api that exemplify this potential problem.

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 65ffad0 | Target commit: 28f8188

lwc-engine-benchmark

table-append-1k metric base(65ffad0) target(28f8188) trend
benchmark-table/append/1k duration 144.35 (± 5.70 ms) 140.10 (± 3.80 ms) 2.94% 👍
table-clear-1k metric base(65ffad0) target(28f8188) trend
benchmark-table/clear/1k duration 11.30 (± 0.40 ms) 11.10 (± 0.60 ms) 1.77% 👌
table-create-10k metric base(65ffad0) target(28f8188) trend
benchmark-table/create/10k duration 833.60 (± 2.90 ms) 837.70 (± 3.80 ms) -0.49% 👎
table-create-1k metric base(65ffad0) target(28f8188) trend
benchmark-table/create/1k duration 101.10 (± 2.35 ms) 99.40 (± 1.90 ms) 1.68% 👌
table-update-10th-1k metric base(65ffad0) target(28f8188) trend
benchmark-table/update-10th/1k duration 85.70 (± 5.80 ms) 83.10 (± 3.70 ms) 3.03% 👌
tablecmp-append-1k metric base(65ffad0) target(28f8188) trend
benchmark-table-component/append/1k duration 240.10 (± 3.70 ms) 241.50 (± 3.50 ms) -0.58% 👌
tablecmp-clear-1k metric base(65ffad0) target(28f8188) trend
benchmark-table/clear/1k duration 35.50 (± 1.40 ms) 35.30 (± 0.90 ms) 0.56% 👌
tablecmp-create-10k metric base(65ffad0) target(28f8188) trend
benchmark-table-component/create/10k duration 1685.50 (± 9.80 ms) 1728.10 (± 13.20 ms) -2.53% 👎
tablecmp-create-1k metric base(65ffad0) target(28f8188) trend
benchmark-table-component/create/1k duration 192.90 (± 4.30 ms) 194.40 (± 3.80 ms) -0.78% 👌
tablecmp-update-10th-1k metric base(65ffad0) target(28f8188) trend
benchmark-table-component/update-10th/1k duration 74.00 (± 5.00 ms) 75.10 (± 5.05 ms) -1.49% 👌

if (key === TargetSlot) {
return false;
}
originalTarget[key] = unwrap(value);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davidturissini @ekashida this is needed because jsdom does support DOM elements as proxies (I suspect because it doesn't have a way to know for sure), while the browser fails on the brand check on the proxy. We need integration tests for these cases here because our units will not capture those failures.

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 65ffad0 | Target commit: 8f06c37

lwc-engine-benchmark

table-append-1k metric base(65ffad0) target(8f06c37) trend
benchmark-table/append/1k duration 144.35 (± 5.70 ms) 142.90 (± 2.60 ms) 1.00% 👌
table-clear-1k metric base(65ffad0) target(8f06c37) trend
benchmark-table/clear/1k duration 11.30 (± 0.40 ms) 11.55 (± 0.65 ms) -2.21% 👌
table-create-10k metric base(65ffad0) target(8f06c37) trend
benchmark-table/create/10k duration 833.60 (± 2.90 ms) 833.50 (± 3.60 ms) 0.01% 👌
table-create-1k metric base(65ffad0) target(8f06c37) trend
benchmark-table/create/1k duration 101.10 (± 2.35 ms) 101.00 (± 1.40 ms) 0.10% 👌
table-update-10th-1k metric base(65ffad0) target(8f06c37) trend
benchmark-table/update-10th/1k duration 85.70 (± 5.80 ms) 87.40 (± 5.70 ms) -1.98% 👌
tablecmp-append-1k metric base(65ffad0) target(8f06c37) trend
benchmark-table-component/append/1k duration 240.10 (± 3.70 ms) 242.50 (± 4.10 ms) -1.00% 👌
tablecmp-clear-1k metric base(65ffad0) target(8f06c37) trend
benchmark-table/clear/1k duration 35.50 (± 1.40 ms) 34.80 (± 1.20 ms) 1.97% 👌
tablecmp-create-10k metric base(65ffad0) target(8f06c37) trend
benchmark-table-component/create/10k duration 1685.50 (± 9.80 ms) 1692.70 (± 11.90 ms) -0.43% 👌
tablecmp-create-1k metric base(65ffad0) target(8f06c37) trend
benchmark-table-component/create/1k duration 192.90 (± 4.30 ms) 193.60 (± 5.20 ms) -0.36% 👌
tablecmp-update-10th-1k metric base(65ffad0) target(8f06c37) trend
benchmark-table-component/update-10th/1k duration 74.00 (± 5.00 ms) 73.40 (± 4.80 ms) 0.81% 👌

@diervo diervo merged commit 7c2ae0a into master Jun 13, 2018
@diervo diervo deleted the caridy/proxy-tests branch June 13, 2018 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants