vomebook commited on
Commit ·
bc37707
1
Parent(s): 2e86106
Let archived article shells grow with their content
Browse filesFiles changed (2)
61 unmodified lines62636465656667686961 unmodified lines// The recognized article's fixed-width archive shell is not a data table.export const LEGACY_ARTICLE_HTML_STYLE = `<style>[data-reader-legacy-article]{display:block!important;box-sizing:border-box!important; inline-size:100%!important;min-inline-size:0!important;max-inline-size:100%!important;float:none!important} inline-size:100%!important;min-inline-size:0!important;max-inline-size:100%!important;float:none!important; block-size:auto!important;max-block-size:none!important}table.center_tdbgall[data-reader-legacy-article]{overflow-x:auto!important}[data-reader-legacy-article] > td:not([data-reader-legacy-article]){max-inline-size:100%!important;overflow-wrap:anywhere}</style>`;3890 unmodified lines389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373890 unmodified lines self.assertEqual(frame.locator('[data-reader-legacy-article]').count(), 0) self.assertEqual(frame.locator('#intervening').evaluate('t => getComputedStyle(t).display'), 'table')
def test_legacy_word_article_fixed_height_does_not_overlap_following_rows(self): image = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7' paragraphs = ''.join(f'<p class="MsoNormal">第{i}段:' + '真实正文应当完整自然换行。' * 8 + '</p>' for i in range(24)) html = ('<!doctype html><meta charset="utf-8"><table class="center_tdbgall" width="960"><tr>' '<td class="main_tdbgall" width="720"><table class="tdbg_top_left_right" width="715">' '<tr><td id="fontzoom" class="main_tdbg_760" height="300" style="max-height:300px">' '<div id="ArticleContent"><div class="Section1">' + paragraphs + f'<p class="MsoNormal"><a href="#note">原脚注</a><img src="{image}" alt="插图"></p>' '<table id="data" style="min-width:800px"><caption>数据表</caption>' '<tr><th>栏目</th><th>内容</th></tr><tr><td>A</td><td>42</td></tr></table>' '<p class="MsoNormal" id="note">正文最后一段</p></div></div>' '<p id="disclaimer">原声明保留</p></td></tr>' '<tr><td id="editor">文章录入:作者 责任编辑:编辑</td></tr>' '</table></td><td>站点侧栏</td></tr></table>') self.serve(html, 'text/html') self.open(self.reader_url('html', name='legacy-fixed-height')) frame = self.page.frame_locator('.html-frame') self.assertEqual(frame.locator('#ArticleContent p.MsoNormal').count(),26) self.assertEqual(frame.locator('#ArticleContent img[alt="插图"]').count(),1) self.assertEqual(frame.locator('#data caption').inner_text(),'数据表') self.assertEqual(frame.locator('a[href="#note"]').count(),1) self.assertEqual(frame.locator('#disclaimer').inner_text(),'原声明保留') for width, zoom in ((390,100),(390,150),(1280,100)): with self.subTest(width=width,zoom=zoom): self.page.set_viewport_size({'width':width,'height':844}) frame.locator('html').evaluate('(n, zoom) => { n.style.zoom = `${zoom}%`; }',zoom) facts = frame.locator('#fontzoom').evaluate('''cell => { const doc=cell.ownerDocument, editor=doc.querySelector('#editor'), disclaimer=doc.querySelector('#disclaimer'); const rect=e=>{const r=e.getBoundingClientRect();return {top:r.top,bottom:r.bottom}}; const data=doc.querySelector('#data'), scroller=data.closest('.reader-ebook-table-scroll'); return {cell:rect(cell), disclaimer:rect(disclaimer), editor:rect(editor), display:getComputedStyle(data).display,scrollable:scroller.scrollWidth>scroller.clientWidth, width:doc.documentElement.clientWidth,scrollWidth:doc.documentElement.scrollWidth}; }''') self.assertGreaterEqual(facts['editor']['top']+1,facts['cell']['bottom'],facts) self.assertGreaterEqual(facts['editor']['top']+1,facts['disclaimer']['bottom'],facts) self.assertEqual(facts['display'],'table') self.assertTrue(facts['scrollable'],facts) self.assertLessEqual(facts['scrollWidth'],facts['width']+1,facts)
def test_discourse_probe_keeps_encoded_and_quirks_mode_class_names(self): for name, prefix, cls, extracted in [('decimal', '<!doctype html>', 'post-stream', True), ('hex', '<!doctype html>', 'post-stream', True),static/reader/ui/reader-document-styles.mjs+2-1
tests/reader/browser/test_reader_refactor.py+41