forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop IsReadableStream* and IsWritableStream* throwing
Previously IsReadableStream, IsReadableStreamDefaultWriter, IsReadableStreamDefaultController, IsWritableStream, IsWritableStreamDefaultWriter and IsWritableStreamDefaultController would throw when passed a null or undefined value. Make them return false instead. Also add CommonOperations.js file. Currently it only contains the function hasOwnPropertyNoThrow() but more will be added later. TBR=brettw@chromium.org Bug: 747772 Change-Id: I06aa2c92de994d547c875c20d54fd50c0551662a Reviewed-on: https://chromium-review.googlesource.com/585030 Commit-Queue: Adam Rice <ricea@chromium.org> Reviewed-by: Takeshi Yoshino <tyoshino@chromium.org> Cr-Commit-Position: refs/heads/master@{#490375}
- Loading branch information
Showing
4 changed files
with
38 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
third_party/WebKit/Source/core/streams/CommonOperations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// Implementation of functions that are shared between ReadableStream and | ||
// WritableStream. | ||
|
||
(function(global, binding, v8) { | ||
'use strict'; | ||
|
||
// Javascript functions. It is important to use these copies for security and | ||
// robustness. See "V8 Extras Design Doc", section "Security Considerations". | ||
// https://docs.google.com/document/d/1AT5-T0aHGp7Lt29vPWFr2-qG8r3l9CByyvKwEuA8Ec0/edit#heading=h.9yixony1a18r | ||
const Boolean = global.Boolean; | ||
const hasOwnProperty = v8.uncurryThis(global.Object.hasOwnProperty); | ||
|
||
function hasOwnPropertyNoThrow(x, property) { | ||
// The cast of |x| to Boolean will eliminate undefined and null, which would | ||
// cause hasOwnProperty to throw a TypeError, as well as some other values | ||
// that can't be objects and so will fail the check anyway. | ||
return Boolean(x) && hasOwnProperty(x, property); | ||
} | ||
|
||
binding.streamOperations = { hasOwnPropertyNoThrow }; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters