찾다
데이터 베이스MySQL 튜토리얼Webkit Layout Test理论部分1 + 深入分析部分2– Layout Test :

原文 : http://blog.csdn.net/yajun0601/article/details/8887332 当我开始做 WebKit 开发的时候,令我好奇的一件事儿就是这玩艺儿怎么测试。作为一个 Web 开发者,我清楚浏览器渲染引擎有多少 bug (尽管现在情况好了很多),以及日益复杂的web 页面给浏览

原文 :

http://blog.csdn.net/yajun0601/article/details/8887332

  当我开始做 WebKit 开发的时候,令我好奇的一件事儿就是这玩艺儿怎么测试。作为一个 Web 开发者,我清楚浏览器渲染引擎有多少 bug (尽管现在情况好了很多),以及日益复杂的web 页面给浏览器引擎带来多大的挑战。伴随bug 一起工作多年自然是要极力避免的事情,所以强制对规范的遵从和避免倒退就显得很关键。


        WebKit 的解决方案就是 layout tests。 从最简单层面来说,layout tests 就是提交到 WebKit 源码库中的一堆简单的网页(越简单越好)和期望的渲染结果文件( golden files),有文本也有图片。测试脚本( run-webkit-tests)使用一个内嵌了 WebKit 的应用(DumpRenderTree)遍历测试用例(现在有30000多了),然后对比这些测试用例的渲染结果和期望结果(golden files),最后将失败、崩溃、超时以及其他和期望不一致的结果生成报告。WebKit 项目中有让 layout test 在已经移植的所有平台上持续运行的编译机,这样就可以容易得发现那些有问题的改动(一旦发现就回滚)。


        鼓励开发者在提交代码前先运行 layout tests。最简单的方式是使用 commit queue,它会自动完成测试的执行。如果不这样,在工作站上运行全部测试用例也是可行的,目前运行一遍大约耗时15分钟,如果使用Dirk Pranke 的 multi-process test runner 时间可以缩短至约 4 分钟或者更少。
通过合理的使用测试数据,layout tests 可以被用来验证很多东西,从 JavaScript 引擎规范一致性到重绘以及 WebSocket 协议的实现。对于类似后者需要访问网络的情况,测试脚本会启动一个本地服务器(Apache, lighthttpd, 或者 WebSocket),然后从服务器上运行测试。本地 HTTP 服务器对模拟网络边界情况也是有用的;让我我觉得很可笑的是,在过去六个月的WebKit 工作中,我被迫学习和使用更多的PHP,比我过去六年做Web开发使用的还要多。


        对于比较简单的测试,他们更多采用了单元测试的形式(比如使用断言),有一个辅助的框架可以让这样的测试很容易的搭建起来。对应的期望结果文件里只是一条条的 "success" 描述。


         考虑到 layout test 不仅仅测试了渲染、布局,同时也包含了 JavaScript bindings的单元测试,网络堆栈的交互测试,数量级性能测试等等,大家也会偶尔讨论到"layout test" 这个名字越来越不精确。也正是由于这样的灵活性,layout test 模型在引入第三方测试套件的时候也有很好的表现。作为 layout test 的一部分,我们还运行了 Sputnik JavaScript 一致性套件,Philip Taylor 的 canvas 套件,以及 HTML5 解析套件,和更多其他浏览器厂商的测试用例。



        

        接下来的一篇会讨论 layout test 系统一些实际的东西,如果要了解更多,请移步 the WebKit wiki.


=============================================================================================

深入分析WebKit之Layout Tests

来自内部一个分享PPT整理过程的知识点,没有特别组织。

 

Layout Test主流程:

Webkit Layout Test理论部分1 + 深入分析部分2– Layout Test :


运行的指令:

  run-webkit-tests [选项] 测试脚本文件或所在的目录
    主要的参数有:

        --verbose  显示详细的信息

        --no-build  不要尝试重新编译dumprendertree

        --debug  使用Debug版本进行测试

        --help  显示所有选项信息


0. 测试方法的归纳

  i. 静态测试  (测试结果是通过比对最终网页输出来决定的。)

四种检测方法: 

Render tree, Body Text, Pixel Data, Ref Test

  (Body Text没有格式信息,而Pixel Data没有文本信息,所以两者是配合使用,以Body Text为主。)

Ref Test是以HTML页面的形式比对。不匹配的结果以图片形式存储。


  ii. 动态测试 (测试结果在执行过程中动态决定。但仍输出到网页,通过静态测试的方式报告出来。)

    动态测试的判断方法和静态测试相同。差异在于比对的内容已经是测试的结果。就是JavaScript脚已经根测试条件和数据,判断出测试成功或失败。然后静态测试的机制输出结果。     

Webkit Layout Test理论部分1 + 深入分析部分2– Layout Test :


测试用例的构成:

   a.测试用HTML文件  (必须在LayoutTests目录下)

{testname}.html

  b.基准文件 (Baseline)

. {testname}-expected.txt  -> Body Text

. {testname}-expected.png  -> Pixel Test

. {testname}-expected.html -> Ref Test 

. {testname}-expected-mismatch.html -> Ref Test

   c.说明

. missmatch类型的测试只有Ref Test支持

. Ref Test具有排它性,如果当前CaseRef Test, 不会再对其它内容检测。

 *关于Audio的比对,脚本里相关内容,但没有再分析。

 *第一次跑测试时,没有比较标准,LayoutTest会自动生成xxx-expected.txt 或xxxx-expected.png。

 *所有测试的网页必须放到LayoutTests目录下。


1. 不要在网页中输出日期或时间。

   (动态变化的内容是不可以拿来比对的)


2. 整个Test Case运行时间不能超过30s。详见另一篇文章。


3. js-test-re.js (配合js-test-post.js使用) 中定义了若干结果确认的函数,如shouldBeTrue.

  如:

  

   …

   <script></script>

     totalCount = 5;

     shouldBeTrue("totalCount == 3");

  

   …

  


运行的结果:

  FAIL totalCount == 3 should be true. Was false.


 其它函数有:shouldBe,shouldBeCloseTo,shouldNotBe,shouldBeFalse,sholdBeNaN,shouldBeNull,shouldBeZero,

shouldBeEqualToString,shouldBeEmptyString,shouldBeDefined,shouldBeUndefined,shouldThrow…

详细地内容可以查看js-test-pre.js脚本。



4. LayoutTests/canvas/tests/23.canvas.reference.html

  ...

 

FAIL (fallback content)


  

       <script></script>

        _addTest(function(canvas, ctx) {

              _assertSame(ctx.canvas, canvas, "ctx.canvas", "canvas");

             });

     


    _assertSame定义在LayoutTests/canvas/test.js中. 


    所有canvas 2D测试使用同相同的id以方便测试脚本执行。


    工作方式 (test.js中的实现):

    Webkit Layout Test理论部分1 + 深入分析部分2– Layout Test :



     测试成功就在网页输出一个Pass, 否则输出错误信息。这样达到比对结果的目的。


    另一个函数:_assertPixel  (2d.clearRect.nonfinite.html)

       _assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");


     函数定义:

       _assertPixel(canvas, x,y, r,g,b,a, pos, colour)  

          pos和colors是代表坐标和颜色的两个字串。函数内没有使用。

            pos : "x,y"

            color: "r,g,b,a"


    函数列表:

      _assert

      _assertSame   (===)

      _assertDifferent  (!==)

      _assertEqual  (==)

      _assertMatch (match) 正则表达式匹配

      _assertPixel  

      _assertPixelApprox 


      _requireManualCheck 因为一些原因取不到数据,可能需要人工检查确认。



    5.对于pixel test,除了dumpAsText()参数设为true, 在运行run-webkit-tests也要指定--pixel参数。 Expected的图像以PNG存储。PNG文件会被保存到对应的platform目录下。

      a. 抓下的图像仅限于可视区域。

      b. 因为字体渲染的原因,尽量不要涉及文本内容。

      c. 因为原生控件(native control)是由系统绘制,不同系统间有差异性。

      参考WebKit的这篇文章。

       


    6.  overridePreference (key, value)

      用于在脚本中动态修改Preference的值。可用的Keys:

          WebKitEnableCaretBrowsing

          WebKitUsePreHTML5ParserQuirks

     *更多的定义在WebPreferencesPrivate.h


    7. Windows下使用LayoutTest的字体问题

      参考:http://trac.webkit.org/wiki/BuildingOnWindows (Font-metric-related failures)

     

    8. 完整的testController方法列表:

      对照代码LayoutTestController.cpp中LayoutTestController::staticFunctions()的定义

    9. 默认的网页视图大小 (DumpRenderTree)

        W3C SVG测试: 480x360

        其它测试:800x600

      *定义在LayoutTestController.cpp:2563 lines, 在函数sizeWebViewForCurrentTest中使用。

      都是常量定义,没有参数可以修改。


    10. 自带DOM测试用例。使用selfhtml.js 和 同html同名的js文件。

      selfhtml.js 提供测试入口函数startTest和9个assert operation供使用: assertSize, assertEqualsCollectionAutoCase

      xxxx.js则提供runTest的实现供startTest调用。

      startTest执行:

          a. waitUntilDone

          b. runTest

          c. notifyDone


    11. 黄金法则:

      a. 对于Pixel Test, 尽量不要涉及文本。

      b. 测试内容不要涉及动态内容,如时间、日期等。




    성명
    본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
    Apple iPhone 16 Pro as Leica smartphone: Leica subsidiary confirms camera grip with official Leica appApple iPhone 16 Pro as Leica smartphone: Leica subsidiary confirms camera grip with official Leica appJun 13, 2024 pm 08:52 PM

    LeicareleasedtheLeicaLuxcameraappfortheAppleiPhoneafewdaysago.However,theappwasnotdevelopedbyLeica,butbyFjorden.ThecompanyhasbeenknownprimarilyforitscameragripsfortheiPhoneandwasacquiredbyLeicainDecember2023.Fo

    Remote 3 universal remote control comes with touchscreen, but without subscription or server obligationRemote 3 universal remote control comes with touchscreen, but without subscription or server obligationJun 14, 2024 am 09:13 AM

    SincethedemiseofLogitech'spopularHarmonyremotecontrols,themarketforhigh-qualityuniversalremotecontrolshasbeenfragmentedatbest.UnfoldedCircleaimstoavoidthefateoftheHarmonyUltimatebyeliminatinganyserverobligationsorsubs

    Samsung Galaxy S24 Ultra gains E Ink secondary display via inventive protective caseSamsung Galaxy S24 Ultra gains E Ink secondary display via inventive protective caseJun 14, 2024 am 10:44 AM

    Anintriguingthird-partycasefortheGalaxyS24Ultra(curr.$1,099.99onAmazon)hasappearedonmarketplaceslikeAliExpress.Astheimagesthroughoutthisarticleshow,thecasehasasimplesiliconeconstruction.However,italsocontainsanEInkd

    Light Phone 3 launches with 50% discount, monochrome OLED and minimalist designLight Phone 3 launches with 50% discount, monochrome OLED and minimalist designJun 13, 2024 pm 10:18 PM

    WhiletheLightPhone2from2018wasstillequippedwithaneconomicale-inkdisplay,theLightPhone3usesanOLEDdisplaythatcanonlydisplaygrayscale.Thereasonfortheswitchtothe3.92-inchOLEDpanelwithitsresolutionof1,240x1,080isth

    Electric Ferraris will boast an \'authentic\' growl, claims marketing executiveElectric Ferraris will boast an \'authentic\' growl, claims marketing executiveJun 14, 2024 am 10:26 AM

    In2012,theeminentautomotivejournalistJeremyClarksonstatedthattheLamborghiniAventador,whichhewasreviewingatthetime,wouldbeamongthelastcarstofeatureanaturallyaspiratedV12.Morethanadecadelater,V12-poweredsupercarsareal

    Jabra discontinues Elite wireless earbuds lineupJabra discontinues Elite wireless earbuds lineupJun 14, 2024 am 09:39 AM

    TheJabraEliteserieshascometoanend,withGNCEOPeterKarlstromerannouncingthediscontinuationofthewirelessearbudswithinthelineupinapressrelease.Petersaysthatthechangingmarketdynamicsandhowchallengingithasbecometogetas

    Audio-Technica unveils ATH-S300BT wireless headphones with hear-through noise-cancellation, 90 hours battery life, and multipoint pairingAudio-Technica unveils ATH-S300BT wireless headphones with hear-through noise-cancellation, 90 hours battery life, and multipoint pairingJun 14, 2024 am 09:46 AM

    Audio-TechnicahasunveiledtheATH-S300BTwirelessheadphoneswithhear-throughnoise-cancellation,multipointpairing,and90hoursofbatterylife.Thenoise-cancellingfeaturehasthreemodes:off,on,andhear-through,whereambientsoundscanbehea

    First complete PCIe 7.0 IP solution presented by Synopsys coming to market in 2025 for HPCs and AI supercomputersFirst complete PCIe 7.0 IP solution presented by Synopsys coming to market in 2025 for HPCs and AI supercomputersJun 14, 2024 am 09:19 AM

    Backin2022,whenPCIe7.0wasstartingtotakeshapeasafuturestandard,PCIe5.0wasjusthittingtheservermarketsandtheprospectofseeingPCIe6.0devicesavailableanytimesoon,letalonePCIe7.0ones,wasquitefar-fetched.CurrentlyPCIe5

    See all articles

    핫 AI 도구

    Undresser.AI Undress

    Undresser.AI Undress

    사실적인 누드 사진을 만들기 위한 AI 기반 앱

    AI Clothes Remover

    AI Clothes Remover

    사진에서 옷을 제거하는 온라인 AI 도구입니다.

    Undress AI Tool

    Undress AI Tool

    무료로 이미지를 벗다

    Clothoff.io

    Clothoff.io

    AI 옷 제거제

    AI Hentai Generator

    AI Hentai Generator

    AI Hentai를 무료로 생성하십시오.

    뜨거운 도구

    안전한 시험 브라우저

    안전한 시험 브라우저

    안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

    DVWA

    DVWA

    DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

    SublimeText3 영어 버전

    SublimeText3 영어 버전

    권장 사항: Win 버전, 코드 프롬프트 지원!

    에디트플러스 중국어 크랙 버전

    에디트플러스 중국어 크랙 버전

    작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

    SublimeText3 Linux 새 버전

    SublimeText3 Linux 새 버전

    SublimeText3 Linux 최신 버전