• 本文来源: developers.google.com/web/updates…
  • 文章作者: Kayce Basques Chrome DevTools & Lighthouse 技术文档工程师
  • 文章 LISENCE: creativecommons.org/licenses/by…
  • 文章中的代码 LISENCE: www.apache.org/licenses/LI…
  • 视频来源: www.youtube.com/watch?v=fJx…
  • 视频 LISENCE: support.google.com/youtube/ans…
  • 译者: 蒋璇, 就职于 丁香园, 任职 Insight 医药数据库 前端开发. 开源社区热爱者

Chrome 71 开发者工具的新特性和主要改动包括:

  • 悬停在 Live Expression 来高亮 DOM 节点
  • 存储 DOM 节点作为全局变量
  • Initiator 和 priority 信息现在在 HAR 导出和导入中
  • 从主菜单访问命令菜单
  • Picture-in-Picture 断点
  • (惊喜提示) 在 Console 运行 monitorEvents() 来监听元素的事件触发

New features and major changes coming to Chrome DevTools in Chrome 71 include:

  • Hover over a Live Expression to highlight a DOM node
  • Store DOM nodes as global variables
  • Initiator and priority information now in HAR imports and exports
  • Access the Command Menu from the Main Menu
  • Picture-in-Picture breakpoints
  • (Bonus Tip) Run monitorEvents() in the Console to watch an element's events fire

继续阅读, 或者是观看该页面的视频版本:

Read on, or watch the video version of this page:

译者注: 视频中提到的 Mordor(摩多) -> en.wikipedia.org/wiki/Mordor

视频说明(源自 YouTube)

New to DevTools in Chrome 71

0:10 → Hover over Live Expression to highlight DOM node

0:46 → Store DOM nodes as global variables

1:19 → Initiator and priority info in HAR file

2:13 → Access Command Menu from Main Menu

2:32 → Bonus Tip!

What’s New in DevTools (Chrome 71) Blog → bit.ly/Chrome71

Discuss these features and changes on the mailing list → goo.gl/RvWtFx Or tweet us → twitter.com/chromedevto…

What's New in DevTools playlist → bit.ly/2JrUPYi

Subscribe to the Google Chrome Developers channel → bit.ly/ChromeDevs1

悬浮在一个 Live Expression 来高亮一个 DOM 节点

Hover over a Live Expression to highlight a DOM node

当一个 Live Expression 的执行结果为一个 DOM 节点时, 悬浮在 Live Expression 的结果之上来在视口中高亮该结果.

When a Live Expression evaluates to a DOM node, hover over the Live Expression result to highlight that node in the viewport.
图片 1. 悬浮在一个 Live Expression 的结果之上来在是口中高亮这个节点
Figure 1. Hovering over a Live Expression result to highlight the node in the viewport

存储 DOM 节点为全局变量

Store DOM nodes as global variables

为了存储一个 DOM 节点为全局变量, 在 Console 中执行一个表达式, 其执行结果为一个节点, 右击执行结果, 然后选择 Store as Global variable.

To store a DOM node as a global variable, run an expression in the Console that evaluates to a node, right-click the result, and then select Store as global variable.
图片 2. 在 Console 中 Store as global variable
Figure 2. Store as global variable in the Console

或者, 在 DOM 树中右击该节点, 然后选择 Store as global variable.

Or, right-click the node in the DOM Tree and select Store as global variable.
图片 3. 在 DOM树 中 Store as global variable
Figure 3. Store as global variable in the DOM Tree

Initiator 和 priority 信息现在存在 HAR 导入和导出中

Initiator and priority information now in HAR imports and exports

如果你想要和同事分享诊断网络的日志, 你可以将网络请求导出到一个 HAR 文件

If you'd like to diagnose network logs with colleagues, you can export the network requests to a HAR file.
图片 4. 导出网络请求到一个 HAR 文件中
Figure 4. Exporting network requests to a HAR file

要导入这个文件回到网络面板中, 只要拖拽和放下该文件(译者注: 必须在网络面板中)

To import the file back into the Network panel, just drag and drop it.

当你导出一个 HAR 文件的时候, DevTools 现在在 HAR 文件中包含 initiator 和 priority 信息. 当你导入一个 HAR 文件回到 DevTools的时候, initiatorPriority 列现在将被填充.

When you export a HAR file, DevTools now includes initiator and priority information in the HAR file. When you import HAR files back into DevTools, the Initiator and Priority columns are now populated.

_initiator 字段提供了有关导致该资源被请求的更多上下文. 其和 Requests 表格中的 Initiator 列相对应.

The _initiator field provides more context around what caused the resource to be requested. This maps to the Initiator column in the Requests table.
图片 5. initiator 列
Figure 5. The initiator column

你可以 按住 Shift 并且悬浮在一个请求 之上来查看它的启动器(译者注: 引起 该请求被发起 的请求)和依赖项(译者注: 依赖该请求的请求)

You can also hold Shift and hover over a request to view its initiator and dependencies.
图片 6. 查看启动器和依赖项
Figure 6. Viewing initiators and dependencies

_priority 字段说明浏览器分配给该资源的优先级. 其和 Requests 表格中的 Priority 列相对应, 这一列默认是隐藏的.

The _priority field states what priority level the browser assigned to the resource. This maps to the Priority column in the Requests table, which is hidden by default.
图片 7. Priority 列
Figure 7. The Priority column

右击 Requests 表格的头部, 然后选择 Priority 来显示 Priority 列.

Right-click the header of the Requests table and select Priority to show the Priority column.
图片 8. 如何展示 Priority
Figure 8. How to show the Priority column
注意: _initiator_priority 字段以下划线开头是因为 HAR 规范 说明自定义的字段必须以下划线开头.

Note: The _initiator and _priority fields begin with underscores because the HAR spec states that custom fields must begin with underscores.

从主菜单进入命令菜单

Access the Command Menu from the Main Menu

使用命令菜单来快速进入 DevTools 面板, 标签, 和特性.

Use the Command Menu for a fast way to access DevTools panels, tabs, and features.
图片 9. 命令菜单
Figure 9. The Command Menu

你现在可以从主菜单打开命令菜单. 点击主菜单 按钮, 然后选择 Run command.

You can now open the Command Menu from the Main Menu. Click the Main Menu button and select Run command.
图片 10. 从主菜单打开命令菜单
Figure 10. Opening the Command Menu from the Main Menu

Picture-in-Picture 断点

Picture-in-Picture breakpoints

Picture-in-picture 是一个新的实验性 API, 其允许一个页面在桌面上面创建一个浮动的视频窗口.

Picture-in-Picture is a new experimental API that enables a page to create a floating video window over the desktop.

在 Event Listener Breakpoints 面板 选中 enterpictureinpicture, leavepictureinpicture, resize 复选框, 来在任意一个 picture-in-picture 事件触发的时候停止执行. DevTools 停止在 处理函数 的第一行.

Enable the enterpictureinpicture, leavepictureinpicture, and resize checkboxes in the Event Listener Breakpoints pane to pause whenever one of these picture-in-picture events fires. DevTools pauses on the first line of the handler.
图片 11. Event Listener Breakpoints 面板下的 Picture-in-Picture 事件
Figure 11. Picture-in-Picture events in the Event Listener Breakpoints pane

(惊喜提示) 在 Console 中执行 monitorEvents() 来监听一个元素的事件触发

(Bonus Tip) Run monitorEvents() in the Console to watch an element's events fire
注意: 该段介绍一个较不为人所知的特性, 但是其已经存在于 DevTools 中很长时间了.

Note: This section covers a lesser-known feature that has been in DevTools for a long time.

假设你想要在这个 button 被聚焦同时依次按下 R, E, D 的时候给它的周围添加一个红色的边框, 但是你不知道要监听什么事件. 使用 monitorEvents() 来在 Console 中打印关于该元素的所有事件.

Suppose you want to add a red border around a button after focusing it and pressing R, E, D, but you don't know what events to add listeners to. Use monitorEvents() to log all of the element's events to the Console.
  1. 获取该节点的一个引用.

    Get a reference to the node.
    图片 12. 使用 Store as global variable 来获取该节点的一个引用
    Figure 12. Using Store as global variable to get a reference to the node
  2. 将该节点作为第一个参数传递给 monitorEvents()
    Pass the node as the first argument to monitorEvents().
    图片 13. 传递该节点给 monitorEvents()
    Figure 13. Passing the node to monitorEvents()
  3. 和该节点做交互. DevTools 在 Console 中打印关于该节点的所有事件.
    Interact with the node. DevTools logs all of the node's events to the Console.
    图片 14. Console 中的该节点的事件
    Figure 14. The node's events in the Console

调用 unmonitorEvents() 来停止在 Console 中打印事件.

Call unmonitorEvents() to stop logging events to the Console.
unmonitorEvents(temp1);
复制代码

如果你只想监听某一个特定的事件或者是某类型的事件, 给 monitorEvents() 传递第二个参数, 其为数组:

Pass an array as the second argument to monitorEvents() if you only want to monitor certain events or types of events:
monitorEvents(temp1, ['mouse', 'focus']);
复制代码

mouse 类型告诉 DevTools 去打印所有和鼠标相关的事件, 比如 mousedownclick. 支持的其他类型为 key, touch, control.

The mouse type tells DevTools to log all mouse-related events, such as mousedown and click. Other supported types are key, touch, and control.

查看 Command Line Reference, 来获得你可以在 Console 中调用的其他方便的函数.

Check out Command Line Reference for other handy functions that you can call from the Console.

反馈

Feedback

想要讨论关于该篇文章的新特性和改动, 或者是其他任何和 DevTools 相关的:

  • 在 Chromium Bugs 发起一个 bug 报告
  • 在 Mailing List 中讨论新特性和改变. 请不要使用该邮件列表寻求帮助. 使用 Stack Overflow, 替代.
  • 使用 Stack Overflow 获取如何使用 DevTools 的帮助. 请不要再 Stack Overflow 上提出 bug. 使用 Chromium Bugs, 替代.
  • Tweet us at @ChromeDevTools.
  • 在 Web Fundamentals 仓库提出关于该文档的 bug.

To discuss the new features and changes in this post, or anything else related to DevTools:

  • File bug reports at Chromium Bugs.
  • Discuss features and changes on the Mailing List. Please don't use the mailing list for support questions. Use Stack Overflow, instead.
  • Get help on how to use DevTools on Stack Overflow. Please don't file bugs on Stack Overflow. Use Chromium Bugs, instead.
  • Tweet us at @ChromeDevTools.
  • File bugs on this doc in the Web Fundamentals repository.

Consider Canary

Consider Canary

如果你使用 Mac 或者是 Windows, 考虑使用 Chrome Canary 作为你的默认开发浏览器. Canary 可以让你体验到最新的 DevTools 特性.(译者注: 译者已经将 Chrome Canary 作为默认浏览器很久了, 为 Web 稍作贡献)

If you're on Mac or Windows, consider using Chrome Canary as your default development browser. Canary gives you access to the latest DevTools features.
注意: Canary 一旦构建就会发布, 没有测试. 这意味着 Canary 几乎每月崩溃一次. 通常在一天之内就会被修复. 在 Canary 崩溃的时候你可以回到使用 Chrome Stable.

Note: Canary is released as soon as its built, without testing. This means that Canary breaks about once-a-month. It's usually fixed within a day. You can go back to using Chrome Stable while Canary is broken.

译者注:

译者在翻译的时候保留了英语原文, 希望给你一个原滋原味的阅读体验并且能熟悉一些常见的英文.

希望有读者可以指出我的翻译错误, 感激不尽.

译文转载请注明出处, 文中所有资源 LISENCE 均跟随源资源.

其他双语译文:

  • React 16.x 蓝图[双语版]

翻译本文时用到的一些工具:

  • 视频下载工具: qdownloader.net/
  • 双语字幕制作工具: arctime.org/index.html
  • 双语字母稿: github.com/Jiang-Xuan/…

开发者工具的新特性 (Chrome 71) [双语+视频]相关推荐

  1. chrome开发者工具_如何使用Chrome开发者工具查找性能瓶颈

    chrome开发者工具 介绍 (Introduction) As one advances through a software development career, concerns beyond ...

  2. php7的核心开发者,php7 五大新特性

    2. 函數返回值類型聲明 官方文檔提供的例子(注意 - 的邊長參數語法在 PHP 5.6 以上的版本中才有): functionarraysSum(array...$arrays):array { r ...

  3. Silverlight 5 beta新特性探索系列:9.视频快进快退和TextSearch对象对文字项查询

    本节讲诉两个新特性:一.在Silverlight 5中可以控制MediaElement对象播放的视频进行快进快退控制.二.在Silverlight 5中的文字项进行搜索查询. 一.对于MediaEle ...

  4. 资源放送丨《 先睹为快!Oracle 20c新特性解析》PPT视频

    前段时间,墨天轮邀请到了云和恩墨CTO.ACDU核心专家."Oracle百科全书" 杨廷琨 老师分享<先睹为快!Oracle 20c新特性解析>,在这里我们共享一下PP ...

  5. 牛!上半年跨境电商进出口增长28.6%;亚马逊日本站自动定价工具增加新功能;TikTok试点视频简历项目…|洞悉跨境

    "上半年,我国跨境电商进出口增长28.6%,市场采购出口增长49.1%. " 每晚八点·洞悉跨境 [海关总署:上半年跨境电商进出口增长28.6%]今日,海关总署新闻发言人.统计分析 ...

  6. 2021 Chrome Devtools 新特性

    目录 基础教程 新特性哪里来的 Chrome 96 Chrome 95 1. CSS的长度单位可直接更换 Chrome 94 1. 支持更换80种语言 2. 设备列表新增Nest Hub 设备 3. ...

  7. 使用 Chrome 开发者工具进行 JavaScript 问题定位与调试

    引言 Google Chrome 是由 Goole 公司开发的一款网页浏览器,自 2008 年 9 月第一个测试版本发布以来,其市场占有率逐步上升,至 2014 年 5 月,Chrome 已超越 Fi ...

  8. Chrome开发者工具-阅读列表

    Chrome的开发者工具是Chrome浏览器内置的编辑和调试利器,熟练使用chrome开发者工具是成为前端修炼的必由之路,来,来,来,一起提高. Chrome开发者工具不完全指南 chrome 开发者 ...

  9. 21-Chrome开发者工具:利用网络面板做性能分析

    浏览器中的页面循环系统"模块我们已经介绍完了,循环系统是页面的基础,理解了循环系统能让我们从本质上更好地理解页面的工作方式,加深我们对一些前端概念的理解. 接下来我们就要进入新的模块了,也就 ...

最新文章

  1. 导频 matlab,v06_03_dem_2up_arrange.m 源代码在线查看 - 完美的OFDM仿真程序MATLAB(带导频),可直接运行 资源下载 虫虫电子下载站...
  2. 如何破除“唯论文”?详解伯克利“科研重工业模式”的成功经验
  3. java日历表打印_Java打印日历表
  4. python和c-Cpython和Jython的对比介绍
  5. DbVisualizer 数据库连接工具:添加数据库驱动方法。dbvis搜索不到驱动文件夹下的驱动解决方法
  6. 常用的排序算法的时间复杂度和空间复杂度 .
  7. JS中数组和字符串具有的方法,以及substring,substr和slice的用法与区别
  8. unity 镜面反射_Unity | Diffuse Light漫反射光照
  9. 【前端基础】浏览器对象
  10. vscode latex 英文语法拼写检查
  11. N1刷armbian,安装cups(惠普打印机)
  12. 2021年中国柠檬酸供需现状与行业前景分析,受出口景气度上升价格持续上涨「图」
  13. 数字人体”视觉挑战赛-宫颈癌风险智能诊断
  14. linux的DRM应用程序,Linux中的DRM
  15. python控制nao机器人身体动作实例
  16. HTML页面循环遍历数据,不用JSTL标签
  17. 2021年安装deepin20.3和windows双系统
  18. try..catch捕获不到空指针等异常的问题
  19. 创维4k电视测试软件,创维4色4K真牛 国产硬件最强电视评测!
  20. 基于深度学习的汽车行业评论文本的情感分析

热门文章

  1. ROM、RAM、DRAM、SRAM和FLAS…
  2. 操作数控雕刻机需要掌握哪些知识
  3. 魅族怎样进入软件测试功能,魅族手机有这些隐藏功能你知道吗?
  4. CTF题库疑惑的汉字
  5. python中item是什么意思中文-Python中使用item()遍历字典
  6. 自动控制原理01 基本概念
  7. 后台任务和PHP-Resque的使用
  8. 腾讯俞栋:AI发展不是独角戏,要与合作伙伴一起AI in All
  9. mklink命令使用教程
  10. Voronoi Noise