Commit 43511968 authored by Dmitry Gozman's avatar Dmitry Gozman Committed by Commit Bot

[DevTools] Migrate inspector-protocol/layout-fonts tests to new test harness

These are the last ones, and we can cleanup now!

BUG=734762

Change-Id: I77457c6b110d081bc9d8247efffe9b65cdeccd3d
Reviewed-on: https://chromium-review.googlesource.com/592406
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: default avatarAndrey Lushnikov <lushnikov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#490795}
parent f0e03cff
...@@ -13179,7 +13179,7 @@ crbug.com/591099 inspector-protocol/emulation/device-emulation-small-dw.js [ Fai ...@@ -13179,7 +13179,7 @@ crbug.com/591099 inspector-protocol/emulation/device-emulation-small-dw.js [ Fai
crbug.com/591099 inspector-protocol/emulation/device-emulation-small.js [ Failure ] crbug.com/591099 inspector-protocol/emulation/device-emulation-small.js [ Failure ]
crbug.com/591099 inspector-protocol/layers/get-layers.js [ Failure ] crbug.com/591099 inspector-protocol/layers/get-layers.js [ Failure ]
crbug.com/591099 inspector-protocol/layers/paint-profiler.js [ Failure ] crbug.com/591099 inspector-protocol/layers/paint-profiler.js [ Failure ]
crbug.com/591099 inspector-protocol/layout-fonts/languages-emoji-rare-glyphs.html [ Failure ] crbug.com/591099 inspector-protocol/layout-fonts/languages-emoji-rare-glyphs.js [ Failure ]
crbug.com/591099 inspector/agents-enable-disable.html [ Failure ] crbug.com/591099 inspector/agents-enable-disable.html [ Failure ]
crbug.com/591099 inspector/animation/animation-KeyframeEffectReadOnly-crash.html [ Crash Failure ] crbug.com/591099 inspector/animation/animation-KeyframeEffectReadOnly-crash.html [ Crash Failure ]
crbug.com/591099 inspector/animation/animation-empty-web-animations.html [ Crash Failure ] crbug.com/591099 inspector/animation/animation-empty-web-animations.html [ Crash Failure ]
...@@ -1428,7 +1428,7 @@ Bug(none) inspector-protocol/heap-profiler/heap-samples-in-snapshot.js [ Failure ...@@ -1428,7 +1428,7 @@ Bug(none) inspector-protocol/heap-profiler/heap-samples-in-snapshot.js [ Failure
Bug(none) inspector-protocol/heap-profiler/heap-snapshot-with-active-dom-object.js [ Failure ] Bug(none) inspector-protocol/heap-profiler/heap-snapshot-with-active-dom-object.js [ Failure ]
Bug(none) inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree.js [ Failure ] Bug(none) inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree.js [ Failure ]
Bug(none) inspector-protocol/heap-profiler/heap-snapshot-with-event-listener.js [ Failure ] Bug(none) inspector-protocol/heap-profiler/heap-snapshot-with-event-listener.js [ Failure ]
Bug(none) inspector-protocol/layout-fonts/unicode-range-combining-chars-fallback.html [ Failure ] Bug(none) inspector-protocol/layout-fonts/unicode-range-combining-chars-fallback.js [ Failure ]
Bug(none) inspector-protocol/network/resource-type.js [ Timeout ] Bug(none) inspector-protocol/network/resource-type.js [ Timeout ]
Bug(none) inspector-protocol/network/websocket-initiator.js [ Timeout ] Bug(none) inspector-protocol/network/websocket-initiator.js [ Timeout ]
Bug(none) inspector-protocol/worker/exception-from-worker-contains-stack.js [ Timeout ] Bug(none) inspector-protocol/worker/exception-from-worker-contains-stack.js [ Timeout ]
......
...@@ -87,7 +87,7 @@ fast/harness/test-expectations.html [ WontFix ] ...@@ -87,7 +87,7 @@ fast/harness/test-expectations.html [ WontFix ]
[ Linux Win Android ] fast/text/aat-morx.html [ WontFix ] [ Linux Win Android ] fast/text/aat-morx.html [ WontFix ]
# Linux layout tests do not have a Myanmar fallback font. # Linux layout tests do not have a Myanmar fallback font.
[ Linux ] inspector-protocol/layout-fonts/fallback-myanmar.html [ WontFix ] [ Linux ] inspector-protocol/layout-fonts/fallback-myanmar.js [ WontFix ]
# Tests in media/stable are only supposed to be run as virtual test (see virtual/stable/media). # Tests in media/stable are only supposed to be run as virtual test (see virtual/stable/media).
media/stable [ WontFix ] media/stable [ WontFix ]
......
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<head>
<script type="text/javascript" src="resources/inspector-protocol-test.js"></script>
<script type="text/javascript" src="resources/css-protocol-test.js"></script>
<script type="text/javascript" src="resources/dom-protocol-test.js"></script>
<script type="text/javascript" src="resources/layout-font-test.js"></script>
</head>
<body>
<div class="test">
<div id="zh-CN" lang="zh-CN">zh-CN: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="zh-TW" lang="zh-TW">zh-TW: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="zh-HK" lang="zh-HK">zh-HK: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="ja" lang="ja">ja: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="ja-JP" lang="ja-JP">ja-JP: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="ko" lang="ko">ko: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="ko-KR" lang="ko-KR">ko-KR: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-CN" lang="en-CN">en-CN: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-JP" lang="en-JP">en-JP: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-KR" lang="en-KR">en-KR: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-HK" lang="en-HK">en-HK: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-TW" lang="en-TW">en-TW: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-HanS" lang="en-HanS">en-HanS: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-HanT" lang="en-HanT">en-HanT: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-HanS-JP" lang="en-HanS-JP">en-HanS-JP: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-HanT-JP" lang="en-HanT-JP">en-HanT-JP: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-US" lang="en-US">en-US: &#x8AA4;&#x904E;&#x9AA8;</div>
</div>
</body>
</html>
(async function(testRunner) {
var page = await testRunner.createPage();
await page.loadHTML(`
<html>
<meta charset="UTF-8">
<body>
<div class="test">
<div id="zh-CN" lang="zh-CN">zh-CN: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="zh-TW" lang="zh-TW">zh-TW: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="zh-HK" lang="zh-HK">zh-HK: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="ja" lang="ja">ja: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="ja-JP" lang="ja-JP">ja-JP: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="ko" lang="ko">ko: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="ko-KR" lang="ko-KR">ko-KR: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-CN" lang="en-CN">en-CN: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-JP" lang="en-JP">en-JP: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-KR" lang="en-KR">en-KR: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-HK" lang="en-HK">en-HK: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-TW" lang="en-TW">en-TW: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-HanS" lang="en-HanS">en-HanS: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-HanT" lang="en-HanT">en-HanT: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-HanS-JP" lang="en-HanS-JP">en-HanS-JP: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-HanT-JP" lang="en-HanT-JP">en-HanT-JP: &#x8AA4;&#x904E;&#x9AA8;</div>
<div id="en-US" lang="en-US">en-US: &#x8AA4;&#x904E;&#x9AA8;</div>
</div>
</body>
</html>
`);
var session = await page.createSession();
var helper = await testRunner.loadScript('./resources/layout-font-test.js');
await helper(testRunner, session);
testRunner.completeTest();
})
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<head>
<script type="text/javascript" src="resources/inspector-protocol-test.js"></script>
<script type="text/javascript" src="resources/css-protocol-test.js"></script>
<script type="text/javascript" src="resources/dom-protocol-test.js"></script>
<script type="text/javascript" src="resources/layout-font-test.js"></script>
</head>
<script>
function postTestHookWithFontResults(results) {
var el = document.createElement("div");
var passed = (results['#myanmar'].length == 1 &&
results['#myanmar'][0].familyName.includes("Myanmar")) ||
(results['#myanmar'].length == 2 &&
results['#myanmar'][0].glyphCount == 2 &&
results['#myanmar'][1].glyphCount > 10 &&
results['#myanmar'][1].familyName.includes("Myanmar"));
el.innerHTML = passed ? "PASS" : "FAIL";
document.body.appendChild(el);
}
</script>
<body>
Test passes if a maxmium of the two first glyphs are notdef's (for Myanmar fonts that do not combine a left quote
with a Myanmar spacing mark and the rest of the run is shaped, given a system Myanmar font is available.
<div class="test">
<div lang="my" id="myanmar">‘ေရွးျမန္မာမင္းေတြလက္ထက္က</div>
</div>
</body>
</html>
(async function(testRunner) {
var page = await testRunner.createPage();
await page.loadHTML(`
<html>
<meta charset="UTF-8">
<body>
<div class="test">
<div lang="my" id="myanmar">‘ေရွးျမန္မာမင္းေတြလက္ထက္က</div>
</div>
</body>
</html>
`);
var session = await page.createSession();
testRunner.log(`Test passes if a maxmium of the two first glyphs are notdef's (for Myanmar fonts that do not combine a left quote with a Myanmar spacing mark and the rest of the run is shaped, given a system Myanmar font is available.`);
var helper = await testRunner.loadScript('./resources/layout-font-test.js');
var results = await helper(testRunner, session);
var myanmar = results.find(x => x.selector === '#myanmar').usedFonts;
var passed = (myanmar.length === 1 && myanmar[0].familyName.includes('Myanmar')) ||
(myanmar.length === 2 && myanmar[0].glyphCount === 2 && myanmar[1].glyphCount > 10 && myanmar[1].familyName.includes('Myanmar'));
testRunner.log(passed ? 'PASS' : 'FAIL');
testRunner.completeTest();
})
<!DOCTYPE html>
<script type="text/javascript" src="resources/inspector-protocol-test.js"></script>
<script type="text/javascript" src="resources/css-protocol-test.js"></script>
<script type="text/javascript" src="resources/dom-protocol-test.js"></script>
<script type="text/javascript" src="resources/layout-font-test.js"></script>
<style>
.test {
font-family: system-ui;
}
#system-ui-20pt {
font-size: 20pt;
}
</style>
<div class="test">
<div id="system-ui">This text should use the system font.</div>
<div id="system-ui-20pt">This text should use the system font.</div>
</div>
(async function(testRunner) {
var page = await testRunner.createPage();
await page.loadHTML(`
<html>
<meta charset="UTF-8">
<style>
.test {
font-family: system-ui;
}
#system-ui-20pt {
font-size: 20pt;
}
</style>
<div class="test">
<div id="system-ui">This text should use the system font.</div>
<div id="system-ui-20pt">This text should use the system font.</div>
</div>
</html>
`);
var session = await page.createSession();
var helper = await testRunner.loadScript('./resources/layout-font-test.js');
await helper(testRunner, session);
testRunner.completeTest();
})
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<head>
<script type="text/javascript" src="resources/inspector-protocol-test.js"></script>
<script type="text/javascript" src="resources/css-protocol-test.js"></script>
<script type="text/javascript" src="resources/dom-protocol-test.js"></script>
<script type="text/javascript" src="resources/layout-font-test.js"></script>
</head>
<body>
<div class="test">
<div lang="zh_Hans" id="hundred_chinese_surnames">百家姓
趙錢孫李 周吳鄭王 馮陳褚衛 蔣沈韓楊 朱秦尤許 何呂施張 孔曹嚴華 金魏陶薑 戚謝鄒喻 柏水竇章 雲蘇潘葛 奚範彭郎 魯韋昌馬 苗鳳花方 俞任袁柳 酆鮑史唐 費廉岑薛 雷賀倪湯 滕殷羅畢 郝鄔安常
樂於時傅 皮卞齊康 伍餘元蔔 顧孟平黃 和穆蕭尹 姚邵堪汪 祁毛禹狄 米貝明臧 計伏成戴 談宋茅龐 熊紀舒屈 項祝董梁 杜阮藍閔 席季麻強 賈路婁危 江童顏郭 梅盛林刁 鍾徐邱駱 高夏蔡田 樊胡淩霍
虞萬支柯 昝管盧莫 經房裘繆 幹解應宗 丁宣賁鄧 鬱單杭洪 包諸左石 崔吉鈕龔 程嵇邢滑 裴陸榮翁 荀羊於惠 甄曲家封 芮羿儲靳 汲邴糜松 井段富巫 烏焦巴弓 牧隗山穀 車侯宓蓬 全郗班仰 秋仲伊宮
寧仇欒暴 甘鈄厲戎 祖武符劉 景詹束龍 葉幸司韶 郜黎薊薄 印宿白懷 蒲台從鄂 索鹹籍賴 卓藺屠蒙 池喬陰鬱 胥能蒼雙 聞莘黨翟 譚貢勞逄 姬申扶堵 冉宰酈雍 卻璩桑桂 濮牛壽通 邊扈燕冀 郟浦尚農
溫別莊晏 柴瞿閻充 慕連茹習 宦艾魚容 向古易慎 戈廖庚終 暨居衡步 都耿滿弘 匡國文寇 廣祿闕東 毆殳沃利 蔚越夔隆 師鞏厙聶 晁勾敖融 冷訾辛闞 那簡饒空 曾毋沙乜 養鞠須豐 巢關蒯相 查後荊紅
遊竺權逯 蓋益桓公 萬俟司馬 上官歐陽 夏侯諸葛 聞人東方 赫連皇甫 尉遲公羊 澹台公冶 宗政濮陽 淳於單於 太叔申屠 公孫仲孫 軒轅令狐 鐘離宇文 長孫慕容 鮮於閭丘 司徒司空 亓官司寇 仉督子車
顓孫端木 巫馬公西 漆雕樂正 壤駟公良 拓拔夾穀 宰父穀粱 晉楚閆法 汝鄢塗欽 段幹百里 東郭南門 呼延歸海 羊舌微生 嶽帥緱亢 況後有琴 梁丘左丘 東門西門 商牟佘佴 伯賞南宮 墨哈譙笪 年愛陽佟
</div>
<div lang="ja" id="japanese_iroha">いろはにほへと ちりぬるを わかよたれそ つねならむ うゐのおくやま けふこえて あさき
ゆめみし ゑひもせす(ん)色は匂へど 散りぬるを 我が世誰ぞ 常ならむ 有為の奥山 今日越えて 浅き夢見じ 酔ひもせず(ん)</div>
<div lang="ko" id="korean_pangram">키스의 고유조건은 입술끼리 만나야 하고 특별한 기술은 필요치 않다.</div>
<div lang="hi" id="hindi_pangram">ऋषियों को सताने वाले दुष्ट राक्षसों के राजा रावण का सर्वनाश करने वाले विष्णुवतार भगवान श्रीराम,
अयोध्या के महाराज दशरथ के बड़े सपुत्र थे।</div>
<div lang="ar" id="arabic_pangram">نصٌّ حكيمٌ لهُ سِرٌّ قاطِعٌ وَذُو شَأنٍ عَظيمٍ مكتوبٌ على ثوبٍ أخضرَ ومُغلفٌ بجلدٍ أزرق</div>
<div id="emoji">🌱🌲🌳🌴🌵🌷🌸🌹🌺🌻🌼💐🌾🌿🍀🍁🍂🍃🍄🌰</div>
<div id="egyptian_hieroglyphs">𓀀𓀁𓀂𓀃𓀄𓀅𓀆𓀇𓀈𓀉𓀊𓀋𓀌𓀍𓀎𓀏</div>
</div>
</body>
</html>
(async function(testRunner) {
var page = await testRunner.createPage();
await page.loadHTML(`
<html>
<meta charset="UTF-8">
<body>
<div class="test">
<div lang="zh_Hans" id="hundred_chinese_surnames">`
+ '百家姓 '
+ '趙錢孫李 周吳鄭王 馮陳褚衛 蔣沈韓楊 朱秦尤許 何呂施張 孔曹嚴華 金魏陶薑 戚謝鄒喻 柏水竇章 雲蘇潘葛 奚範彭郎 魯韋昌馬 苗鳳花方 俞任袁柳 酆鮑史唐 費廉岑薛 雷賀倪湯 滕殷羅畢 郝鄔安常 '
+ '樂於時傅 皮卞齊康 伍餘元蔔 顧孟平黃 和穆蕭尹 姚邵堪汪 祁毛禹狄 米貝明臧 計伏成戴 談宋茅龐 熊紀舒屈 項祝董梁 杜阮藍閔 席季麻強 賈路婁危 江童顏郭 梅盛林刁 鍾徐邱駱 高夏蔡田 樊胡淩霍 '
+ '虞萬支柯 昝管盧莫 經房裘繆 幹解應宗 丁宣賁鄧 鬱單杭洪 包諸左石 崔吉鈕龔 程嵇邢滑 裴陸榮翁 荀羊於惠 甄曲家封 芮羿儲靳 汲邴糜松 井段富巫 烏焦巴弓 牧隗山穀 車侯宓蓬 全郗班仰 秋仲伊宮 '
+ '寧仇欒暴 甘鈄厲戎 祖武符劉 景詹束龍 葉幸司韶 郜黎薊薄 印宿白懷 蒲台從鄂 索鹹籍賴 卓藺屠蒙 池喬陰鬱 胥能蒼雙 聞莘黨翟 譚貢勞逄 姬申扶堵 冉宰酈雍 卻璩桑桂 濮牛壽通 邊扈燕冀 郟浦尚農 '
+ '溫別莊晏 柴瞿閻充 慕連茹習 宦艾魚容 向古易慎 戈廖庚終 暨居衡步 都耿滿弘 匡國文寇 廣祿闕東 毆殳沃利 蔚越夔隆 師鞏厙聶 晁勾敖融 冷訾辛闞 那簡饒空 曾毋沙乜 養鞠須豐 巢關蒯相 查後荊紅 '
+ '遊竺權逯 蓋益桓公 萬俟司馬 上官歐陽 夏侯諸葛 聞人東方 赫連皇甫 尉遲公羊 澹台公冶 宗政濮陽 淳於單於 太叔申屠 公孫仲孫 軒轅令狐 鐘離宇文 長孫慕容 鮮於閭丘 司徒司空 亓官司寇 仉督子車 '
+ '顓孫端木 巫馬公西 漆雕樂正 壤駟公良 拓拔夾穀 宰父穀粱 晉楚閆法 汝鄢塗欽 段幹百里 東郭南門 呼延歸海 羊舌微生 嶽帥緱亢 況後有琴 梁丘左丘 東門西門 商牟佘佴 伯賞南宮 墨哈譙笪 年愛陽佟'
+ `</div>
<div lang="ja" id="japanese_iroha">いろはにほへと ちりぬるを わかよたれそ つねならむ うゐのおくやま けふこえて あさき ゆめみし ゑひもせす(ん)色は匂へど 散りぬるを 我が世誰ぞ 常ならむ 有為の奥山 今日越えて 浅き夢見じ 酔ひもせず(ん)</div>
<div lang="ko" id="korean_pangram">키스의 고유조건은 입술끼리 만나야 하고 특별한 기술은 필요치 않다.</div>
<div lang="hi" id="hindi_pangram">ऋषियों को सताने वाले दुष्ट राक्षसों के राजा रावण का सर्वनाश करने वाले विष्णुवतार भगवान श्रीराम, अयोध्या के महाराज दशरथ के बड़े सपुत्र थे।</div>
<div lang="ar" id="arabic_pangram">نصٌّ حكيمٌ لهُ سِرٌّ قاطِعٌ وَذُو شَأنٍ عَظيمٍ مكتوبٌ على ثوبٍ أخضرَ ومُغلفٌ بجلدٍ أزرق</div>
<div id="emoji">🌱🌲🌳🌴🌵🌷🌸🌹🌺🌻🌼💐🌾🌿🍀🍁🍂🍃🍄🌰</div>
<div id="egyptian_hieroglyphs">𓀀𓀁𓀂𓀃𓀄𓀅𓀆𓀇𓀈𓀉𓀊𓀋𓀌𓀍𓀎𓀏</div>
</div>
</body>
</html>
`);
var session = await page.createSession();
var helper = await testRunner.loadScript('./resources/layout-font-test.js');
await helper(testRunner, session);
testRunner.completeTest();
})
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<head>
<script type="text/javascript" src="resources/inspector-protocol-test.js"></script>
<script type="text/javascript" src="resources/css-protocol-test.js"></script>
<script type="text/javascript" src="resources/dom-protocol-test.js"></script>
<script type="text/javascript" src="resources/layout-font-test.js"></script>
</head>
<body>
<!-- All ogham glyps in two font families. -->
<div class="test">
<div id=oghammonofont></div>
<div id=oghamdefaultfont></div>
<script>
function makeCharHtml(charCode) {
return "&#x" + charCode.toString(16) + ";";
}
function makeCharHtmlSequence(first, last) {
var result = "";
for (var i = first; i <= last; i++)
result += makeCharHtml(i);
return result;
}
charSequenceHtml = makeCharHtmlSequence(0x1680, 0x169c);
document.getElementById("oghammonofont").innerHTML = charSequenceHtml;
document.getElementById("oghamdefaultfont").innerHTML = charSequenceHtml;
</script>
</div>
There should be two lines of
<a href="https://en.wikipedia.org/wiki/Ogham">Ogham</a> above.
</body>
</html>
(async function(testRunner) {
var page = await testRunner.createPage();
await page.loadHTML(`
<html>
<meta charset="UTF-8">
<body>
<!-- All ogham glyps in two font families. -->
<div class="test">
<div id=oghammonofont></div>
<div id=oghamdefaultfont></div>
</div>
</body>
</html>
`);
var session = await page.createSession();
await session.evaluate(`
function makeCharHtml(charCode) {
return "&#x" + charCode.toString(16) + ";";
}
function makeCharHtmlSequence(first, last) {
var result = "";
for (var i = first; i <= last; i++)
result += makeCharHtml(i);
return result;
}
charSequenceHtml = makeCharHtmlSequence(0x1680, 0x169c);
document.getElementById("oghammonofont").innerHTML = charSequenceHtml;
document.getElementById("oghamdefaultfont").innerHTML = charSequenceHtml;
`);
var helper = await testRunner.loadScript('./resources/layout-font-test.js');
await helper(testRunner, session);
testRunner.log('There should be two lines of Ogham above.');
testRunner.completeTest();
})
function initialize_cssTest()
{
InspectorTest.dumpStyleSheetText = function(styleSheetId, callback)
{
InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onStyleSheetText);
function onStyleSheetText(result)
{
InspectorTest.log("==== Style sheet text ====");
InspectorTest.log(result.text);
callback();
}
}
function modifyStyleSheet(command, presetStyleSheetId, styleSheetId, expectError, options, callback)
{
if (presetStyleSheetId)
options.styleSheetId = styleSheetId;
if (expectError)
InspectorTest.sendCommand(command, options, onResponse);
else
InspectorTest.sendCommandOrDie(command, options, onSuccess);
function onSuccess()
{
InspectorTest.dumpStyleSheetText(styleSheetId, callback);
}
function onResponse(message)
{
if (!message.error) {
InspectorTest.log("ERROR: protocol method call did not return expected error. Instead, the following message was received: " + JSON.stringify(message));
InspectorTest.completeTest();
return;
}
InspectorTest.log("Expected protocol error: " + message.error.message + (message.error.data ? " (" + message.error.data + ")" : ""));
callback();
}
}
InspectorTest.setPropertyText = modifyStyleSheet.bind(null, "CSS.setPropertyText", true);
InspectorTest.setRuleSelector = modifyStyleSheet.bind(null, "CSS.setRuleSelector", true);
InspectorTest.setMediaText = modifyStyleSheet.bind(null, "CSS.setMediaText", true);
InspectorTest.addRule = modifyStyleSheet.bind(null, "CSS.addRule", true);
InspectorTest.setStyleTexts = function(styleSheetId, expectError, edits, callback)
{
var options = { edits: edits };
modifyStyleSheet("CSS.setStyleTexts", false, styleSheetId, expectError, options, callback);
}
InspectorTest.requestMainFrameId = function(callback)
{
InspectorTest.sendCommandOrDie("Page.enable", {}, pageEnabled);
function pageEnabled()
{
InspectorTest.sendCommandOrDie("Page.getResourceTree", {}, resourceTreeLoaded);
}
function resourceTreeLoaded(payload)
{
callback(payload.frameTree.frame.id);
}
};
function indentLog(indent, string)
{
var indentString = Array(indent+1).join(" ");
InspectorTest.log(indentString + string);
}
InspectorTest.dumpRuleMatch = function(ruleMatch)
{
var rule = ruleMatch.rule;
var matchingSelectors = ruleMatch.matchingSelectors;
var media = rule.media || [];
var mediaLine = "";
for (var i = 0; i < media.length; ++i)
mediaLine += (i > 0 ? " " : "") + media[i].text;
var baseIndent = 0;
if (mediaLine.length) {
indentLog(baseIndent, "@media " + mediaLine);
baseIndent += 4;
}
var selectorLine = "";
var selectors = rule.selectorList.selectors;
for (var i = 0; i < selectors.length; ++i) {
if (i > 0)
selectorLine += ", ";
var matching = matchingSelectors.indexOf(i) !== -1;
if (matching)
selectorLine += "*";
selectorLine += selectors[i].text;
if (matching)
selectorLine += "*";
}
selectorLine += " {";
selectorLine += " " + rule.origin;
if (!rule.style.styleSheetId)
selectorLine += " readonly";
indentLog(baseIndent, selectorLine);
InspectorTest.dumpStyle(rule.style, baseIndent);
indentLog(baseIndent, "}");
};
InspectorTest.dumpStyle = function(style, baseIndent)
{
if (!style)
return;
var cssProperties = style.cssProperties;
for (var i = 0; i < cssProperties.length; ++i) {
var cssProperty = cssProperties[i];
var propertyLine = cssProperty.name + ": " + cssProperty.value + ";";
indentLog(baseIndent + 4, propertyLine);
}
}
InspectorTest.displayName = function(url)
{
return url.substr(url.lastIndexOf("/") + 1);
};
InspectorTest.loadAndDumpMatchingRulesForNode = function(nodeId, callback, omitLog)
{
InspectorTest.sendCommandOrDie("CSS.getMatchedStylesForNode", { "nodeId": nodeId }, matchingRulesLoaded);
function matchingRulesLoaded(result)
{
if (!omitLog)
InspectorTest.log("Dumping matched rules: ");
dumpRuleMatches(result.matchedCSSRules);
if (!omitLog)
InspectorTest.log("Dumping inherited rules: ");
for (var inheritedEntry of result.inherited) {
InspectorTest.dumpStyle(inheritedEntry.inlineStyle);
dumpRuleMatches(inheritedEntry.matchedCSSRules);
}
callback();
}
function dumpRuleMatches(ruleMatches)
{
for (var ruleMatch of ruleMatches) {
var origin = ruleMatch.rule.origin;
if (origin !== "inspector" && origin !== "regular")
continue;
InspectorTest.dumpRuleMatch(ruleMatch);
}
}
}
InspectorTest.loadAndDumpCSSAnimationsForNode = function(nodeId, callback)
{
InspectorTest.sendCommandOrDie("CSS.getMatchedStylesForNode", { "nodeId": nodeId }, cssAnimationsLoaded);
function cssAnimationsLoaded(result)
{
InspectorTest.log("Dumping CSS keyframed animations: ");
for (var keyframesRule of result.cssKeyframesRules) {
InspectorTest.log("@keyframes " + keyframesRule.animationName.text + " {");
for (var keyframe of keyframesRule.keyframes) {
indentLog(4, keyframe.keyText.text + " {");
InspectorTest.dumpStyle(keyframe.style, 4);
indentLog(4, "}");
}
InspectorTest.log("}");
}
callback();
}
}
InspectorTest.loadAndDumpMatchingRules = function(documentNodeId, selector, callback, omitLog)
{
InspectorTest.requestNodeId(documentNodeId, selector, nodeIdLoaded);
function nodeIdLoaded(nodeId)
{
InspectorTest.loadAndDumpMatchingRulesForNode(nodeId, callback, omitLog);
}
}
InspectorTest.loadAndDumpInlineAndMatchingRules = function(documentNodeId, selector, callback, omitLog)
{
InspectorTest.requestNodeId(documentNodeId, selector, nodeIdLoaded);
var nodeId;
function nodeIdLoaded(id)
{
nodeId = id;
InspectorTest.sendCommandOrDie("CSS.getInlineStylesForNode", { "nodeId": nodeId }, onInline);
}
function onInline(result)
{
if (!omitLog)
InspectorTest.log("Dumping inline style: ");
InspectorTest.log("{");
InspectorTest.dumpStyle(result.inlineStyle, 0);
InspectorTest.log("}");
InspectorTest.loadAndDumpMatchingRulesForNode(nodeId, callback, omitLog)
}
}
}
function initialize_domTest()
{
InspectorTest.trackGetChildNodesEvents = function(nodeInfo, callback)
{
InspectorTest.eventHandler["DOM.setChildNodes"] = setChildNodes;
function setChildNodes(message)
{
var nodes = message.params.nodes;
for (var i = 0; i < nodes.length; ++i)
InspectorTest.addNode(nodeInfo, nodes[i]);
if (callback)
callback();
}
}
InspectorTest.addNode = function(nodeInfo, node)
{
nodeInfo[node.nodeId] = node;
delete node.nodeId;
var children = node.children || [];
for (var i = 0; i < children.length; ++i)
InspectorTest.addNode(nodeInfo, children[i]);
var shadowRoots = node.shadowRoots || [];
for (var i = 0; i < shadowRoots.length; ++i)
InspectorTest.addNode(nodeInfo, shadowRoots[i]);
}
InspectorTest.requestDocumentNodeId = async function(callback)
{
var result = await InspectorTest.sendCommandOrDie("DOM.getDocument", {});
if (callback)
callback(result.root.nodeId);
return result.root.nodeId;
};
InspectorTest.requestNodeId = async function(documentNodeId, selector, callback)
{
var result = await InspectorTest.sendCommandOrDie("DOM.querySelector", { "nodeId": documentNodeId , "selector": selector });
if (callback)
callback(result.nodeId);
return result.nodeId;
};
}
/*
* Copyright (C) 2012 Samsung Electronics. All rights reserved.
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
var initialize_InspectorTest = function() {
InspectorTest.evaluateInInspectedPage = function(expression, callback)
{
InspectorTest.sendCommand("Runtime.evaluate", { expression: expression }, callback);
}
InspectorTest.parseURL = function(url)
{
var result = {};
var match = url.match(/^([^:]+):\/\/([^\/:]*)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i);
if (!match)
return result;
result.scheme = match[1].toLowerCase();
result.host = match[2];
result.port = match[3];
result.path = match[4] || "/";
result.fragment = match[5];
return result;
}
}
var outputElement;
/**
* Logs message to process stdout via alert (hopefully implemented with immediate flush).
* @param {string} text
*/
function debugLog(text)
{
alert(text);
}
/**
* @param {string} text
*/
function log(text)
{
if (!outputElement) {
var intermediate = document.createElement("div");
document.body.appendChild(intermediate);
var intermediate2 = document.createElement("div");
intermediate.appendChild(intermediate2);
outputElement = document.createElement("div");
outputElement.className = "output";
outputElement.id = "output";
outputElement.style.whiteSpace = "pre";
intermediate2.appendChild(outputElement);
}
outputElement.appendChild(document.createTextNode(text));
outputElement.appendChild(document.createElement("br"));
}
function closeTest()
{
closeInspector();
testRunner.notifyDone();
}
var reloadParam = "__protocol__test__reload__";
function runTest()
{
if (!window.testRunner) {
console.error("This test requires DumpRenderTree");
return;
}
var reloadIndex = window.location.href.lastIndexOf(reloadParam);
if (reloadIndex !== -1) {
var lastId = window.location.href.substring(reloadIndex + reloadParam.length);
window.lastFrontendEvalId = parseInt(lastId, 10);
evaluateInFrontend("InspectorTest.pageReloaded();");
return;
}
testRunner.dumpAsText();
testRunner.waitUntilDone();
testRunner.setCanOpenWindows(true);
openInspector();
}
function closeInspector()
{
testRunner.closeWebInspector();
}
var lastFrontendEvalId = 0;
function evaluateInFrontend(script)
{
testRunner.evaluateInWebInspector(++lastFrontendEvalId, script);
}
function navigateProtocolTest(url)
{
url += (url.indexOf("?") === -1 ? "?" : "&") + reloadParam + lastFrontendEvalId;
window.location.replace(url);
}
function prepareForReload()
{
window.location += "#" + reloadParam + lastFrontendEvalId;
}
function openInspector()
{
var scriptTags = document.getElementsByTagName("script");
var scriptUrlBasePath = "";
for (var i = 0; i < scriptTags.length; ++i) {
var index = scriptTags[i].src.lastIndexOf("/resources/inspector-protocol-test.js");
if (index > -1 ) {
scriptUrlBasePath = scriptTags[i].src.slice(0, index);
break;
}
}
var dummyFrontendURL = scriptUrlBasePath + "/resources/protocol-test.html";
testRunner.showWebInspector("", dummyFrontendURL);
// FIXME: rename this 'test' global field across all tests.
var testFunction = window.test;
if (typeof testFunction === "function") {
var initializers = "";
for (var symbol in window) {
if (!/^initialize_/.test(symbol) || typeof window[symbol] !== "function")
continue;
initializers += "(" + window[symbol].toString() + ")();\n";
}
evaluateInFrontend(initializers + "(" + testFunction.toString() +")();");
return;
}
// Kill waiting process if failed to send.
alert("Failed to send test function");
testRunner.notifyDone();
}
function test() (async function layoutFontTest(testRunner, session) {
{ var documentNodeId = (await session.protocol.DOM.getDocument()).result.root.nodeId;
var documentNodeId; await session.protocol.CSS.enable();
var documentNodeSelector; var testNodes = await session.evaluate(`
var testSelectors = []; Array.prototype.map.call(document.querySelectorAll('.test *'), e => ({selector: '#' + e.id, textContent: e.textContent}))
var collectedFontUsage = {}; `);
InspectorTest.requestDocumentNodeId(onDocumentNodeId); for (var testNode of testNodes) {
var nodeId = (await session.protocol.DOM.querySelector({nodeId: documentNodeId , selector: testNode.selector})).result.nodeId;
function onDocumentNodeId(nodeId) var response = await session.protocol.CSS.getPlatformFontsForNode({nodeId});
{ var usedFonts = response.result.fonts;
documentNodeId = nodeId; usedFonts.sort((a, b) => b.glyphCount - a.glyphCount);
InspectorTest.evaluateInInspectedPage( testRunner.log(testNode.textContent);
'JSON.stringify(' + testRunner.log(testNode.selector + ':');
'Array.prototype.map.call(' + for (var i = 0; i < usedFonts.length; i++) {
'document.querySelectorAll(".test *"),' + var usedFont = usedFonts[i];
'function(element) { return element.id } ));', var isLast = i === usedFonts.length - 1;
testPageElements); testRunner.log(`"${usedFont.familyName}" : ${usedFont.glyphCount}${isLast ? '' : ','}`);
} }
testRunner.log('');
testNode.usedFonts = usedFonts;
function testPageElements(result) }
{ return testNodes;
testSelectors = JSON.parse(result.result.result.value); })
testNextPageElement();
}
function testNextPageElement()
{
var nextSelector = testSelectors.shift()
if (nextSelector) {
documentNodeSelector = "#" + nextSelector;
platformFontsForElementWithSelector(documentNodeSelector);
} else {
reportAndComplete();
}
}
function reportAndComplete()
{
postResultsToPage();
InspectorTest.completeTest();
}
function postResultsToPage()
{
// This interleaves the used fonts data with the page elements so that
// the content_shell text dump is easier to validate.
InspectorTest.evaluateInInspectedPage("injectCollectedResultsInPage(" +
JSON.stringify(collectedFontUsage) +
")");
InspectorTest.evaluateInInspectedPage("postTestHookWithFontResults(" +
JSON.stringify(collectedFontUsage) +
")");
}
async function platformFontsForElementWithSelector(selector)
{
var nodeId = await InspectorTest.requestNodeId(documentNodeId, selector);
await InspectorTest.sendCommandOrDie("CSS.enable", {});
var response = await InspectorTest.sendCommandOrDie("CSS.getPlatformFontsForNode", { nodeId: nodeId });
collectResults(response);
testNextPageElement();
}
function collectResults(response)
{
var usedFonts = response.fonts;
usedFonts.sort(function(a, b) {
return b.glyphCount - a.glyphCount;
});
collectedFontUsage[documentNodeSelector] = usedFonts;
}
};
function formatResult(selector, resultForSelector)
{
var resultFormatted = selector + ":\n";
for (var i = 0; i < resultForSelector.length; i++) {
resultFormatted += '"' + resultForSelector[i].familyName + '"' +
" : " +
resultForSelector[i].glyphCount;
if (i + 1 < resultForSelector.length)
resultFormatted += ",\n";
else
resultFormatted += "\n\n";
}
return resultFormatted;
}
function injectCollectedResultsInPage(results)
{
for (nodeSelector in results) {
var testNode = document.querySelector(nodeSelector);
var resultElement = document.createElement("div");
var resultTextPre = document.createElement("pre");
var resultText = formatResult(nodeSelector, results[nodeSelector]);
var resultTextNode = document.createTextNode(resultText);
resultTextPre.appendChild(resultTextNode);
resultElement.appendChild(resultTextPre);
testNode.parentNode.insertBefore(resultElement, testNode.nextSibling);
}
}
window.addEventListener("DOMContentLoaded", function () {
runTest();
}, false);
<!DOCTYPE html> (async function(testRunner) {
<html> var page = await testRunner.createPage();
<meta charset="UTF-8"> await page.loadHTML(`
<head> <html>
<script type="text/javascript" src="resources/inspector-protocol-test.js"></script> <meta charset="UTF-8">
<script type="text/javascript" src="resources/css-protocol-test.js"></script>
<script type="text/javascript" src="resources/dom-protocol-test.js"></script>
<script type="text/javascript" src="resources/layout-font-test.js"></script>
</head>
<body>
<div class="test"> <div class="test">
<!-- Universal declaration of Human Rights written in Central <!-- Universal declaration of Human Rights written in Central
Atlas Tamazight using Tifinagh script. --> Atlas Tamazight using Tifinagh script. -->
<div id="tifinagh_text">ⵉⵎⴷⴰⵏⴻⵏ, ⴰⴽⴽⴻⵏ ⵎⴰ ⵍⵍⴰⵏ ⵜⵜⵍⴰⵍⴻⵏ ⴷ ⵉⵍⴻⵍⵍⵉⵢⴻⵏ ⵎⵙⴰⵡⴰⵏ ⴷⵉ ⵍⵃⵡⴻⵕⵎⴰ ⴷ ⵢⵉⵣⴻⵔⴼⴰⵏ-ⵖⵓⵔ ⵙⴻⵏ ⵜⴰⵎⵙⴰⴽⵡⵉⵜ ⴷ ⵍⴰⵇⵓⴻⵍ ⵓ ⵢⴻⵙⵙⴻⴼⴽ ⴰⴷ-ⵜⵉⵍⵉ ⵜⴻⴳⵎⴰⵜⵜ ⴳⴰⵔ ⴰⵙⴻⵏ <div id="tifinagh_text">ⵉⵎⴷⴰⵏⴻⵏ, ⴰⴽⴽⴻⵏ ⵎⴰ ⵍⵍⴰⵏ ⵜⵜⵍⴰⵍⴻⵏ ⴷ ⵉⵍⴻⵍⵍⵉⵢⴻⵏ ⵎⵙⴰⵡⴰⵏ ⴷⵉ ⵍⵃⵡⴻⵕⵎⴰ ⴷ ⵢⵉⵣⴻⵔⴼⴰⵏ-ⵖⵓⵔ ⵙⴻⵏ ⵜⴰⵎⵙⴰⴽⵡⵉⵜ ⴷ ⵍⴰⵇⵓⴻⵍ ⵓ ⵢⴻⵙⵙⴻⴼⴽ ⴰⴷ-ⵜⵉⵍⵉ ⵜⴻⴳⵎⴰⵜⵜ ⴳⴰⵔ ⴰⵙⴻⵏ</div>
</div> </html>
</body> `);
</html> var session = await page.createSession();
var helper = await testRunner.loadScript('./resources/layout-font-test.js');
await helper(testRunner, session);
testRunner.completeTest();
})
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<head>
<script type="text/javascript" src="resources/inspector-protocol-test.js"></script>
<script type="text/javascript" src="resources/css-protocol-test.js"></script>
<script type="text/javascript" src="resources/dom-protocol-test.js"></script>
<script type="text/javascript" src="resources/layout-font-test.js"></script>
<style type="text/css">
/* fallback */
@font-face {
font-family: 'Tinos';
font-style: normal;
font-weight: 700;
src: url("../../third_party/Tinos/tinos-bold.ttf");
}
/* latin */
@font-face {
font-family: 'Tinos';
font-style: normal;
font-weight: 700;
src: url("../../third_party/Tinos/tinos-subset.woff2");
unicode-range: U+0000-00FF;
}
body {
position: relative;
font-family: "Tinos", Times, serif;
font-weight: 600;
font-size: 80px;
}
</style>
</head>
<body>
<div class="test">
<div id="should_be_using_only_tinos">ẽĩj̃j́m̃p̃q̃s̃t̃ũỹẼĨJ̃J́M̃P̃Q̃S̃T̃ŨỸ¿</div>
</div>
</body>
</html>
(async function(testRunner) {
var page = await testRunner.createPage();
await page.loadHTML(`
<html>
<meta charset="UTF-8">
<style type="text/css">
/* fallback */
@font-face {
font-family: 'Tinos';
font-style: normal;
font-weight: 700;
src: url("../../third_party/Tinos/tinos-bold.ttf");
}
/* latin */
@font-face {
font-family: 'Tinos';
font-style: normal;
font-weight: 700;
src: url("../../third_party/Tinos/tinos-subset.woff2");
unicode-range: U+0000-00FF;
}
body {
position: relative;
font-family: "Tinos", Times, serif;
font-weight: 600;
font-size: 80px;
}
</style>
<body>
<div class="test">
<div id="should_be_using_only_tinos">ẽĩj̃j́m̃p̃q̃s̃t̃ũỹẼĨJ̃J́M̃P̃Q̃S̃T̃ŨỸ¿</div>
</div>
</body>
</html>
`);
var session = await page.createSession();
var helper = await testRunner.loadScript('./resources/layout-font-test.js');
await helper(testRunner, session);
testRunner.completeTest();
})
...@@ -7,3 +7,4 @@ ...@@ -7,3 +7,4 @@
"DejaVu Sans" : 29 "DejaVu Sans" : 29
There should be two lines of Ogham above. There should be two lines of Ogham above.
...@@ -7,3 +7,4 @@ ...@@ -7,3 +7,4 @@
"Geneva" : 29 "Geneva" : 29
There should be two lines of Ogham above. There should be two lines of Ogham above.
...@@ -7,3 +7,4 @@ ...@@ -7,3 +7,4 @@
"Noto Sans Ogham" : 29 "Noto Sans Ogham" : 29
There should be two lines of Ogham above. There should be two lines of Ogham above.
...@@ -7,3 +7,4 @@ ...@@ -7,3 +7,4 @@
"Noto Sans Ogham" : 29 "Noto Sans Ogham" : 29
There should be two lines of Ogham above. There should be two lines of Ogham above.
...@@ -4,3 +4,4 @@ Test passes if a maxmium of the two first glyphs are notdef's (for Myanmar fonts ...@@ -4,3 +4,4 @@ Test passes if a maxmium of the two first glyphs are notdef's (for Myanmar fonts
"Myanmar MN" : 22 "Myanmar MN" : 22
PASS PASS
...@@ -7,3 +7,4 @@ ...@@ -7,3 +7,4 @@
"Geneva" : 29 "Geneva" : 29
There should be two lines of Ogham above. There should be two lines of Ogham above.
...@@ -4,3 +4,4 @@ Test passes if a maxmium of the two first glyphs are notdef's (for Myanmar fonts ...@@ -4,3 +4,4 @@ Test passes if a maxmium of the two first glyphs are notdef's (for Myanmar fonts
"Myanmar Text" : 26 "Myanmar Text" : 26
PASS PASS
...@@ -7,3 +7,4 @@ ...@@ -7,3 +7,4 @@
"Segoe UI Historic" : 29 "Segoe UI Historic" : 29
There should be two lines of Ogham above. There should be two lines of Ogham above.
...@@ -4,3 +4,4 @@ Test passes if a maxmium of the two first glyphs are notdef's (for Myanmar fonts ...@@ -4,3 +4,4 @@ Test passes if a maxmium of the two first glyphs are notdef's (for Myanmar fonts
"Arial" : 25 "Arial" : 25
FAIL FAIL
...@@ -7,3 +7,4 @@ ...@@ -7,3 +7,4 @@
"Segoe UI Symbol" : 29 "Segoe UI Symbol" : 29
There should be two lines of Ogham above. There should be two lines of Ogham above.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment