WebKit Bugzilla
Attachment 343855 Details for
Bug 187159
: Fix a bug ComponentBase that wrong content template may be used.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-187159-20180628145648.patch (text/plain), 4.98 KB, created by
dewei_zhu
on 2018-06-28 14:56:48 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
dewei_zhu
Created:
2018-06-28 14:56:48 PDT
Size:
4.98 KB
patch
obsolete
>Subversion Revision: 233326 >diff --git a/Websites/perf.webkit.org/ChangeLog b/Websites/perf.webkit.org/ChangeLog >index 9f7feb0a60f5ba0591631937c54e9645da59d518..766a8990e2c76118e3a5af22790114abbefa817b 100644 >--- a/Websites/perf.webkit.org/ChangeLog >+++ b/Websites/perf.webkit.org/ChangeLog >@@ -1,3 +1,18 @@ >+2018-06-28 Dewei Zhu <dewei_zhu@apple.com> >+ >+ Fix a bug ComponentBase that wrong content template may be used. >+ https://bugs.webkit.org/show_bug.cgi?id=187159 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ ComponentBase uses '_parsed' to mark whether content and style templates of a class >+ is parsed. However, derived class parsing will be skipped as 'Derive._parsed' is available >+ via prototype chain whenever the base class is parsed. >+ >+ * browser-tests/component-base-tests.js: Added unit tests. >+ * public/v3/components/base.js: Added 'hasOwnProperty' to make sure current class is parsed. >+ (ComponentBase.prototype._ensureShadowTree): >+ > 2018-06-25 Dewei Zhu <dewei_zhu@apple.com> > > MeasurementSetAnalyzer should check triggerable availability before creating confirming A/B tests. >diff --git a/Websites/perf.webkit.org/browser-tests/component-base-tests.js b/Websites/perf.webkit.org/browser-tests/component-base-tests.js >index adef69f58f8a3411d1532d38fc2f7963ea0f221b..4418f81997a7d72ffe690d5f40ce0c77eaf4d778 100644 >--- a/Websites/perf.webkit.org/browser-tests/component-base-tests.js >+++ b/Websites/perf.webkit.org/browser-tests/component-base-tests.js >@@ -195,6 +195,27 @@ describe('ComponentBase', function() { > expect(container.textContent).to.be('hello, world'); > }); > >+ it('it must create content using derived class content template', async () => { >+ const context = new BrowsingContext(); >+ const ComponentBase = await importComponentBase(context); >+ >+ class BaseClass extends ComponentBase { }; >+ BaseClass.contentTemplate = ['div', {id: 'container'}, 'base-class']; >+ const baseInstance = new BaseClass('base-class'); >+ >+ class DerivedClass extends BaseClass {}; >+ DerivedClass.contentTemplate = ['div', {id: 'container'}, 'derived-class']; >+ const derivedInstance = new DerivedClass('derived-class'); >+ >+ const baseContainer = baseInstance.content('container'); >+ expect(baseContainer).to.be.a(context.global.HTMLDivElement); >+ expect(baseContainer.textContent).to.be('base-class'); >+ >+ const derivedContainer = derivedInstance.content('container'); >+ expect(derivedContainer).to.be.a(context.global.HTMLDivElement); >+ expect(derivedContainer.textContent).to.be('derived-class'); >+ }); >+ > it('it must create stylsheet from styleTemplate', async () => { > const context = new BrowsingContext(); > const ComponentBase = await importComponentBase(context); >@@ -699,4 +720,28 @@ describe('ComponentBase', function() { > > }); > >+ describe('_ensureShadowTree', () => { >+ it('should parse derived component after parsing base component', async () => { >+ const context = new BrowsingContext(); >+ const ComponentBase = await importComponentBase(context); >+ class DerivedComponent extends ComponentBase {}; >+ const baseInstance = new ComponentBase; >+ expect(ComponentBase.hasOwnProperty('_parsed')).to.be(false); >+ expect(DerivedComponent.hasOwnProperty('_parsed')).to.be(false); >+ >+ baseInstance._ensureShadowTree(); >+ expect(ComponentBase.hasOwnProperty('_parsed')).to.be(true); >+ expect(DerivedComponent.hasOwnProperty('_parsed')).to.be(false); >+ expect(!!ComponentBase._parsed).to.be(true); >+ expect(!!DerivedComponent._parsed).to.be(true); >+ >+ const derivedInstance = new DerivedComponent; >+ derivedInstance._ensureShadowTree(); >+ expect(ComponentBase.hasOwnProperty('_parsed')).to.be(true); >+ expect(DerivedComponent.hasOwnProperty('_parsed')).to.be(true); >+ expect(!!ComponentBase._parsed).to.be(true); >+ expect(!!DerivedComponent._parsed).to.be(true); >+ }); >+ }); >+ > }); >diff --git a/Websites/perf.webkit.org/public/v3/components/base.js b/Websites/perf.webkit.org/public/v3/components/base.js >index 42ed8fe4c266fcb4ecec21ae0d9acb0411e562ec..317517705db8d324191d12915c76a098be6aab9d 100644 >--- a/Websites/perf.webkit.org/public/v3/components/base.js >+++ b/Websites/perf.webkit.org/public/v3/components/base.js >@@ -154,9 +154,8 @@ class ComponentBase extends CommonComponentBase { > > let content; > let stylesheet; >- if (!thisClass._parsed) { >+ if (!thisClass.hasOwnProperty('_parsed') || !thisClass._parsed) { > thisClass._parsed = true; >- > const contentTemplate = thisClass['contentTemplate']; > if (contentTemplate) > content = ComponentBase._constructNodeTreeFromTemplate(contentTemplate);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
rniwa
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 187159
: 343855