Google heeft versie 66 van zijn webbrowser Chrome uitgebracht. Google Chrome is beschikbaar voor Windows, Linux en macOS. Er zijn ook versies voor Android en iOS, maar die volgen een iets ander releaseschema. Sinds versie 50 is de ondersteuning voor oudere versies van Windows en macOS vervallen. In deze uitgave wordt onder meer een beperkte test gedaan met Site Isololation om zo de gevolgen van Spectre tegen te gaan en de beveiliging in het algemeen aan te scherpen.
Site Isolation Trial
Chrome 66 will include a small percentage trial of Site Isolation, to prepare for a broader upcoming launch. Site Isolation improves Chrome's security and helps mitigate the risks posed by Spectre.To diagnose whether an issue is caused by Site Isolation, use chrome://flags#site-isolation-trial-opt-out as described here. Please report any trial-specific issues to help us fix them before Site Isolation is launched more broadly.
The ImageBitmap Rendering Context for <canvas>
Historically, rendering an image to a canvas has involved first creating an<img>
tag and then rendering its contents to a canvas. This causes multiple copies of the image to be stored in memory. A new rendering context streamlines the display ofImageBitmap
objects by avoiding memory duplication and rendering them more efficiently. This example shows how to do this using anImageBitmapRenderingContext
. This essentially transfers ownership of an image's pixels. This example does so from a blob to a<canvas>
, but pixels can be moved between<canvas>
elements as well. Note that the blob is compressed so it is not a full copy in memory.const image = await createImageBitmap(imageBlob); const canvas = document.createElement('canvas'); const context = canvas.getContext('bitmaprenderer'); context.transferFromImageBitmap(image); canvas.toBlob((outputJPEGBlob) => { // Do something with outputJPEGBlob. }, 'image/jpeg');If this were done withoutcreateImageBitmap()
, theimageBlob
would be lazily decoded, which would cause jank. On the other handcreateImageBitmap()
is asynchronous which allows you to decode it completely before using it and avoiding jank. For example, a WebGL game could use this to load new textures on the fly as gameplay progresses.
CSS Typed Object Model
Historically, developers wanting to manipulate CSS properties have had to manipulate strings only for the browser to then convert it back to a typed representation. What made things worse was when developers tried to read the value of a CSS property in Javascript, this typed value was converted back to a string. In version 66, Chrome implements the CSS Typed Object Model (OM) Level 1, a part of Houdini, for a subset of CSS properties. Typed OM reduces this burden on both the developer and browser by exposing CSS values as typed JavaScript objects rather than strings. Along with allowing the performant manipulation of values assigned to CSS properties, Typed OM allows developers to write more maintainable and easy to understand code. A brief example illustrates the point. Previously if I wanted to set the opacity of an element I could do this:el.style.opacity = 0.3; el.style.opacity === "0.3"With CSSOM:el.attributeStyleMap.set("opacity", CSS.number("0.3")); el.attributeStyleMap.get("opacity").value === 0.3The returned values above are of typeCSSUnitValue
, which are easier to manipulate than strings.
Asynchronous Clipboard API
The new asynchronous clipboard API provides a promise-based means of reading from and writing to the clipboard. It's simpler than the oldexecCommand('copy')
API released in Chrome 43 and integrates with the Permissions API. Future Chrome releases will also support copy/paste of richer types of data, including images. To get a taste of this API, lets do simple write and read operations with text.try { await navigator.clipboard.writeText("Hello, clipboard."); } catch { console.error("Unable to write to clipboard."); }Similarly, to read text back:const data = await navigator.clipboard.readText(); console.log("From the clipboard:", data);For more information, including how to use security and permissions with the API, read Unblocking Clipboard Access and check out our sample.
AudioWorklet
The legacyScriptProcessorNode
was asynchronous and required thread hops, which could produce an unstable audio output. TheAudioWorklet
object provides a new synchronous JavaScript execution context which allows developers to programmatically control audio without additional latency and higher stability in the output audio. You can see example code in action along with other examples at Google Chrome Labs. In addition to AudioWorklet, other worklet API are being built.PaintWorklet
was released in Chrome 65/Opera 52. AnAnimationWorklet
is planned.ScriptProcessorNode
will be deprecated some time afterAudioWorklet
ships.
Blink > Animation
The add and accumulate compositing operations are intended for building modularized animations. Theadd
andaccumulate
keywords will be supported in Chrome soon. Until then, they will no longer throw errors. This is to maintain compatibility with Firefox and other implementations.
Blink > CSS
CSS has two new features.Blink > Feature Policy
- The mathematical expressions
calc(),
min()
, andmax()
are now supported in media queries, as required by the CSS Values and Units Module Level 4 specification. This change brings them in line with other types of rules where these functions are allowed anywhere a number is allowed.- Floating point values are now allowed in the
rgb()
andrgba()
functions.
By default, thedeviceorientation
,deviceorientationabsolute
, anddevicemotion
events are now restricted to top-level document and same-origin subframes, the same as if the feature policy for those features were set to'self'
. To modify this behavior, explicitly enable or disable the specific feature.
Blink > File API
The File API now results in a network error instead of a 404 when attempting to read from an invalid or non-existing blob URL.
Blink > Forms
HTML forms have two new features.Blink > Fullscreen
- The
<textarea>
element and the<select>
element now support theautocomplete
attribute as required by the specification.- A mutable checkbox now fires three events as required by the HTML specification: a
click
event, then aninput
event, then achange
event. Formerly only theclick
andchange
events were fired.
If a page in fullscreen mode opens a popup and callswindow.focus(),
that page exits full screen. This does not occur if the popup receives focus some other way.
Blink > GetUserMedia
A new method on theMediaStreamTrack
interface calledgetCapabilities()
returns aMediaTrackCapabilities
object, which specifies the values or range of values which each constrianable property. Capabilities vary by device.
Blink > JavaScript
There are several JavaScript changes.Blink > Layout
- The
Function.prototype.toString()
function now returns exactly what is written in the source code. This includes whitespace and other text that may have been used. For example, if there is a comment between the function keyword and the function name, the comment is now returned in addition to the keyword and name.- JSON is now a syntactic subset of ECMAScript, which allows line separator (U+2028) and paragraph separator (U+2029) symbols in string literals.
- The
catch
clause of atry
statement can now be used without a parameter.String.prototype.trimStart()
andString.prototype.trimEnd()
are now available as the standards-based way of trimming whitespace from strings, in addition toString.prototype.trim()
which was already implemented. The non-standardtrimLeft()
andtrimRight()
remain as aliases of the new methods for backward compatibility.- The
Array.prototype.values()
method returns a new array iterator object that contains the values for each index in the array.
Layout has two new features.
- The grid prefix has been removed from the CSS gutter properties:
grid-gap
becomesgap
grid-row-gap
becomesrow-gap
grid-column-gap
becomescolumn-gap
The default value for all three isnormal
and the prefixed properties are aliases of the new ones. Note thatcolumn-gap
property already exists and is used bycss-multicol
.Blink > Media
- Elements with the display properties
table-row
,table-row-group
,table-header-group
,table-footer-group
,table-cell
, andtable-caption
that have a transform property are now containing blocks for fixed position elements. Blink currently does not make<tr>
,<tbody>
,<tfoot>
, and<thead>
be containing blocks for fixed-position elements.
Media has two new features.Blink > Network
- As announced earlier,
autoplay
is now allowed only when either the media won't play sound, after the user clicks or taps on the site, or (on desktop) if the user has previously shown an interest in media on the site. This will reduce unexpected video playbacks with sound when first opening a web page.- The Media Capabilities, Decoding Info API allows websites to get more information about the decoding abilities of the client. This enables more informed selection of media streams for the user, avoiding scenarios such as where the client is unable to smoothly and power-efficiently decode a resolution that might have been picked based only on available bandwidth and screen size.
The Fetch API has two new features.
- The Request object now supports a
keepalive
property which allows a fetch to continue after a tab is closed. This feature is invoked by passing a boolean in the constructor's initialization object. Its value can be read back from the object itself. This property can be used withsendBeacon()
as well.- New
AbortSignal
andAbortController
interfaces allow a fetch to be canceled. To accomplish this create anAbortController
object and pass its signal property as an option tofetch
. CallingabortController.abort()
cancels the fetch. There's more information in our abortable fetch article, but a small code example is shown below.const controller = new AbortController(); const signal = controller.signal; const requestPromise = fetch(url, { signal }); // Abort the fetch: controller.abort();
Blink > ServiceWorker
Service workers have two changes.Blink > WebRTC
- A service worker can no longer respond to a request whose mode is
same-origin
with a response whose type isCORS
. This is a security measure recently added to the Fetch specification.FetchEvent.clientId
now returns an empty string instead of null when it isn't set. For example, this can occur during a navigation request.
Chrome now supports theRTCRtpSender.dtmf
attribute per the specification. This replaces theCreateDTMFSender()
function which has not yet been deprecated.
Deprecations and Interoperability Improvements
Blink > CSS
Theobject-position
andperspective-origin
properties no longer accepts three-part values such astop right 20%
. This change also applies to basic shapes and gradients. Valid position values must always have 1, 2, or 4 parts.
Blink > HTML
Following a specification change,ImageCapture.prototype.setOptions()
has been removed.
Blink > Input
Following a specification change,document.createTouch()
anddocument.createTouchList()
have been removed.
Blink > Web Audio
Following a specification change, automatic dezippering ofAudioParam.prototype.value
changes was removed from Chrome. If you need to smooth the value ofAudioParam
changes, useAudioParam.prototype.setTargetAtTime()
.