<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[203766] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/203766">203766</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-07-26 23:37:49 -0700 (Tue, 26 Jul 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>JS Built-ins should throw this-error messages consistently with binding generated code
https://bugs.webkit.org/show_bug.cgi?id=160191
Patch by Youenn Fablet <youennf@gmail.com> on 2016-07-26
Reviewed by Darin Adler.
Source/WebCore:
Introducing @makeThisTypeError and @makeGetterTypeError to create TypeError objects with a consistent error message.
Making use of these functions in streams API and fetch API related built-in code.
Refactored JSDOMBinding.cpp code by adding makeThisTypeErrorMessage and makeGetterTypeErrorMessage helper routines
These routines are used by both new built-in functions as well as binding generated code helper routine.
Tests: fetch/fetch-error-messages.html
streams/readable-stream-error-messages.html
* Modules/fetch/FetchResponse.js:
(body): Adding an explicit check so that the error message is right. The previous error message was related to the call of Response.@isDisturbed.
* Modules/streams/ReadableStream.js:
(cancel):
(getReader):
(pipeTo):
(tee):
(locked):
* Modules/streams/ReadableStreamController.js:
(enqueue):
(error):
(close):
(desiredSize):
* Modules/streams/ReadableStreamReader.js:
(cancel):
(read):
(releaseLock):
(closed):
* bindings/js/JSDOMBinding.cpp:
(WebCore::makeGetterTypeErrorMessage):
(WebCore::throwGetterTypeError):
(WebCore::makeThisTypeErrorMessage):
(WebCore::throwThisTypeError):
(WebCore::throwSequenceTypeError): Deleted.
(WebCore::throwSetterTypeError): Deleted.
* bindings/js/JSDOMBinding.h:
* bindings/js/JSDOMGlobalObject.cpp:
(WebCore::makeThisTypeErrorForBuiltins):
(WebCore::makeGetterTypeErrorForBuiltins):
(WebCore::JSDOMGlobalObject::addBuiltinGlobals):
* bindings/js/WebCoreBuiltinNames.h:
LayoutTests:
* fetch/fetch-error-messages-expected.txt: Added.
* fetch/fetch-error-messages.html: Added.
* streams/readable-stream-error-messages-expected.txt: Added.
* streams/readable-stream-error-messages.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchResponsejs">trunk/Source/WebCore/Modules/fetch/FetchResponse.js</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsReadableStreamjs">trunk/Source/WebCore/Modules/streams/ReadableStream.js</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsReadableStreamControllerjs">trunk/Source/WebCore/Modules/streams/ReadableStreamController.js</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsReadableStreamReaderjs">trunk/Source/WebCore/Modules/streams/ReadableStreamReader.js</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMBindingcpp">trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMBindingh">trunk/Source/WebCore/bindings/js/JSDOMBinding.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMGlobalObjectcpp">trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsWebCoreBuiltinNamesh">trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfetchfetcherrormessagesexpectedtxt">trunk/LayoutTests/fetch/fetch-error-messages-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfetchfetcherrormessageshtml">trunk/LayoutTests/fetch/fetch-error-messages.html</a></li>
<li><a href="#trunkLayoutTestsstreamsreadablestreamerrormessagesexpectedtxt">trunk/LayoutTests/streams/readable-stream-error-messages-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsreadablestreamerrormessageshtml">trunk/LayoutTests/streams/readable-stream-error-messages.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (203765 => 203766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-07-27 06:35:30 UTC (rev 203765)
+++ trunk/LayoutTests/ChangeLog        2016-07-27 06:37:49 UTC (rev 203766)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-07-26 Youenn Fablet <youennf@gmail.com>
+
+ JS Built-ins should throw this-error messages consistently with binding generated code
+ https://bugs.webkit.org/show_bug.cgi?id=160191
+
+ Reviewed by Darin Adler.
+
+ * fetch/fetch-error-messages-expected.txt: Added.
+ * fetch/fetch-error-messages.html: Added.
+ * streams/readable-stream-error-messages-expected.txt: Added.
+ * streams/readable-stream-error-messages.html: Added.
+
</ins><span class="cx"> 2016-07-26 Myles C. Maxfield <mmaxfield@apple.com>
</span><span class="cx">
</span><span class="cx"> [iOS] SF-Heavy is inaccessible by web content
</span></span></pre></div>
<a id="trunkLayoutTestsfetchfetcherrormessagesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fetch/fetch-error-messages-expected.txt (0 => 203766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fetch/fetch-error-messages-expected.txt         (rev 0)
+++ trunk/LayoutTests/fetch/fetch-error-messages-expected.txt        2016-07-27 06:37:49 UTC (rev 203766)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+CONSOLE MESSAGE: line 11: TypeError: The Response.body getter can only be used on instances of Response
+
+PASS Exercising TypeError messages in Fetch Response
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfetchfetcherrormessageshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fetch/fetch-error-messages.html (0 => 203766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fetch/fetch-error-messages.html         (rev 0)
+++ trunk/LayoutTests/fetch/fetch-error-messages.html        2016-07-27 06:37:49 UTC (rev 203766)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+<!DOCTYPE html>
+<script src='../resources/testharness.js'></script>
+<script src='../resources/testharnessreport.js'></script>
+<script>
+function printMethodError(method, target)
+{
+ try {
+ method.call(target);
+ assert_unreached();
+ } catch(e) {
+ console.log(e);
+ }
+}
+
+function printGetterError(object, getterName, target)
+{
+ const getter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(object), getterName).get;
+ printMethodError(getter, target);
+}
+
+test(function(test) {
+ // This test prints exceptions to check the format of their messages.
+
+ var request = new Request("");
+ var response = new Response("");
+
+ printGetterError(response, "body", request);
+
+}, "Exercising TypeError messages in Fetch Response");
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsstreamsreadablestreamerrormessagesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/streams/readable-stream-error-messages-expected.txt (0 => 203766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/readable-stream-error-messages-expected.txt         (rev 0)
+++ trunk/LayoutTests/streams/readable-stream-error-messages-expected.txt        2016-07-27 06:37:49 UTC (rev 203766)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+CONSOLE MESSAGE: line 11: TypeError: Can only call ReadableStream.getReader on instances of ReadableStream
+CONSOLE MESSAGE: line 11: TypeError: Can only call ReadableStream.tee on instances of ReadableStream
+CONSOLE MESSAGE: line 11: TypeError: The ReadableStream.locked getter can only be used on instances of ReadableStream
+CONSOLE MESSAGE: line 11: TypeError: Can only call ReadableStreamController.enqueue on instances of ReadableStreamController
+CONSOLE MESSAGE: line 11: TypeError: Can only call ReadableStreamController.error on instances of ReadableStreamController
+CONSOLE MESSAGE: line 11: TypeError: Can only call ReadableStreamController.close on instances of ReadableStreamController
+CONSOLE MESSAGE: line 11: TypeError: The ReadableStreamController.desiredSize getter can only be used on instances of ReadableStreamController
+CONSOLE MESSAGE: line 11: TypeError: Can only call ReadableStreamReader.releaseLock on instances of ReadableStreamReader
+CONSOLE MESSAGE: line 18: TypeError: Can only call ReadableStream.cancel on instances of ReadableStream
+CONSOLE MESSAGE: line 18: TypeError: Can only call ReadableStreamReader.cancel on instances of ReadableStreamReader
+CONSOLE MESSAGE: line 18: TypeError: Can only call ReadableStreamReader.read on instances of ReadableStreamReader
+CONSOLE MESSAGE: line 18: TypeError: The ReadableStreamReader.closed getter can only be used on instances of ReadableStreamReader
+
+PASS Exercising TypeError messages in ReadableStream, ReadableStreamController and ReadableStreamReader
+
</ins></span></pre></div>
<a id="trunkLayoutTestsstreamsreadablestreamerrormessageshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/streams/readable-stream-error-messages.html (0 => 203766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/readable-stream-error-messages.html         (rev 0)
+++ trunk/LayoutTests/streams/readable-stream-error-messages.html        2016-07-27 06:37:49 UTC (rev 203766)
</span><span class="lines">@@ -0,0 +1,63 @@
</span><ins>+<!DOCTYPE html>
+<script src='../resources/testharness.js'></script>
+<script src='../resources/testharnessreport.js'></script>
+<script>
+function printMethodError(method, target)
+{
+ try {
+ method.call(target);
+ assert_unreached();
+ } catch(e) {
+ console.log(e);
+ }
+}
+
+function printPromiseMethodError(method, target)
+{
+ return method.call(target).then(assert_unreached, (e) => {
+ console.log(e);
+ });
+}
+
+function printGetterError(object, getterName, target)
+{
+ const getter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(object), getterName).get;
+ printMethodError(getter, target);
+}
+
+function printPromiseGetterError(object, getterName, target)
+{
+ const getter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(object), getterName).get;
+ printPromiseMethodError(getter, target);
+}
+
+promise_test(function(test) {
+ // This test prints exceptions to check the format of their messages.
+ var controller;
+ var stream = new ReadableStream({
+ start: (c) => {
+ controller = c;
+ }
+ });
+ var reader = stream.getReader();
+
+ var results = [];
+
+ results.push(printPromiseMethodError(stream.cancel, controller));
+ results.push(printMethodError(stream.getReader, controller));
+ results.push(printMethodError(stream.tee, controller));
+ results.push(printGetterError(stream, "locked", controller));
+
+ results.push(printMethodError(controller.enqueue, reader));
+ results.push(printMethodError(controller.error, reader));
+ results.push(printMethodError(controller.close, reader));
+ results.push(printGetterError(controller, "desiredSize", reader));
+
+ results.push(printPromiseMethodError(reader.cancel, stream));
+ results.push(printPromiseMethodError(reader.read, stream));
+ results.push(printMethodError(reader.releaseLock, stream));
+ results.push(printPromiseGetterError(reader, "closed", stream));
+
+ return Promise.all(results);
+}, "Exercising TypeError messages in ReadableStream, ReadableStreamController and ReadableStreamReader");
+</script>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (203765 => 203766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-07-27 06:35:30 UTC (rev 203765)
+++ trunk/Source/WebCore/ChangeLog        2016-07-27 06:37:49 UTC (rev 203766)
</span><span class="lines">@@ -1,3 +1,51 @@
</span><ins>+2016-07-26 Youenn Fablet <youennf@gmail.com>
+
+ JS Built-ins should throw this-error messages consistently with binding generated code
+ https://bugs.webkit.org/show_bug.cgi?id=160191
+
+ Reviewed by Darin Adler.
+
+ Introducing @makeThisTypeError and @makeGetterTypeError to create TypeError objects with a consistent error message.
+ Making use of these functions in streams API and fetch API related built-in code.
+
+ Refactored JSDOMBinding.cpp code by adding makeThisTypeErrorMessage and makeGetterTypeErrorMessage helper routines
+ These routines are used by both new built-in functions as well as binding generated code helper routine.
+
+ Tests: fetch/fetch-error-messages.html
+ streams/readable-stream-error-messages.html
+
+ * Modules/fetch/FetchResponse.js:
+ (body): Adding an explicit check so that the error message is right. The previous error message was related to the call of Response.@isDisturbed.
+ * Modules/streams/ReadableStream.js:
+ (cancel):
+ (getReader):
+ (pipeTo):
+ (tee):
+ (locked):
+ * Modules/streams/ReadableStreamController.js:
+ (enqueue):
+ (error):
+ (close):
+ (desiredSize):
+ * Modules/streams/ReadableStreamReader.js:
+ (cancel):
+ (read):
+ (releaseLock):
+ (closed):
+ * bindings/js/JSDOMBinding.cpp:
+ (WebCore::makeGetterTypeErrorMessage):
+ (WebCore::throwGetterTypeError):
+ (WebCore::makeThisTypeErrorMessage):
+ (WebCore::throwThisTypeError):
+ (WebCore::throwSequenceTypeError): Deleted.
+ (WebCore::throwSetterTypeError): Deleted.
+ * bindings/js/JSDOMBinding.h:
+ * bindings/js/JSDOMGlobalObject.cpp:
+ (WebCore::makeThisTypeErrorForBuiltins):
+ (WebCore::makeGetterTypeErrorForBuiltins):
+ (WebCore::JSDOMGlobalObject::addBuiltinGlobals):
+ * bindings/js/WebCoreBuiltinNames.h:
+
</ins><span class="cx"> 2016-07-26 Carlos Garcia Campos <cgarcia@igalia.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed. Fix GTK+ distcheck build.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchResponsejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.js (203765 => 203766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchResponse.js        2016-07-27 06:35:30 UTC (rev 203765)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.js        2016-07-27 06:37:49 UTC (rev 203766)
</span><span class="lines">@@ -56,6 +56,9 @@
</span><span class="cx">
</span><span class="cx"> function body()
</span><span class="cx"> {
</span><ins>+ if (!(this instanceof @Response))
+ throw @makeGetterTypeError("Response", "body");
+
</ins><span class="cx"> if (!this.@body) {
</span><span class="cx"> if (@Response.prototype.@isDisturbed.@call(this)) {
</span><span class="cx"> this.@body = new @ReadableStream();
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsReadableStreamjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/ReadableStream.js (203765 => 203766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/ReadableStream.js        2016-07-27 06:35:30 UTC (rev 203765)
+++ trunk/Source/WebCore/Modules/streams/ReadableStream.js        2016-07-27 06:37:49 UTC (rev 203766)
</span><span class="lines">@@ -71,7 +71,7 @@
</span><span class="cx"> "use strict";
</span><span class="cx">
</span><span class="cx"> if (!@isReadableStream(this))
</span><del>- return @Promise.@reject(new @TypeError("Function should be called on a ReadableStream"));
</del><ins>+ return @Promise.@reject(@makeThisTypeError("ReadableStream", "cancel"));
</ins><span class="cx">
</span><span class="cx"> if (@isReadableStreamLocked(this))
</span><span class="cx"> return @Promise.@reject(new @TypeError("ReadableStream is locked"));
</span><span class="lines">@@ -84,7 +84,7 @@
</span><span class="cx"> "use strict";
</span><span class="cx">
</span><span class="cx"> if (!@isReadableStream(this))
</span><del>- throw new @TypeError("Function should be called on a ReadableStream");
</del><ins>+ throw @makeThisTypeError("ReadableStream", "getReader");
</ins><span class="cx">
</span><span class="cx"> return new @ReadableStreamReader(this);
</span><span class="cx"> }
</span><span class="lines">@@ -186,7 +186,7 @@
</span><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> doPipe();
</span><del>-
</del><ins>+
</ins><span class="cx"> return promiseCapability.@promise;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -195,7 +195,7 @@
</span><span class="cx"> "use strict";
</span><span class="cx">
</span><span class="cx"> if (!@isReadableStream(this))
</span><del>- throw new @TypeError("Function should be called on a ReadableStream");
</del><ins>+ throw @makeThisTypeError("ReadableStream", "tee");
</ins><span class="cx">
</span><span class="cx"> return @teeReadableStream(this, false);
</span><span class="cx"> }
</span><span class="lines">@@ -205,7 +205,7 @@
</span><span class="cx"> "use strict";
</span><span class="cx">
</span><span class="cx"> if (!@isReadableStream(this))
</span><del>- throw new @TypeError("Function should be called on a ReadableStream");
</del><ins>+ throw @makeGetterTypeError("ReadableStream", "locked");
</ins><span class="cx">
</span><span class="cx"> return @isReadableStreamLocked(this);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsReadableStreamControllerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamController.js (203765 => 203766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/ReadableStreamController.js        2016-07-27 06:35:30 UTC (rev 203765)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamController.js        2016-07-27 06:37:49 UTC (rev 203766)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> "use strict";
</span><span class="cx">
</span><span class="cx"> if (!@isReadableStreamController(this))
</span><del>- throw new @TypeError("Function should be called on a ReadableStreamController");
</del><ins>+ throw @makeThisTypeError("ReadableStreamController", "enqueue");
</ins><span class="cx">
</span><span class="cx"> const stream = this.@controlledReadableStream;
</span><span class="cx">
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx"> "use strict";
</span><span class="cx">
</span><span class="cx"> if (!@isReadableStreamController(this))
</span><del>- throw new @TypeError("Function should be called on a ReadableStreamController");
</del><ins>+ throw @makeThisTypeError("ReadableStreamController", "error");
</ins><span class="cx">
</span><span class="cx"> const stream = this.@controlledReadableStream;
</span><span class="cx"> if (stream.@state !== @streamReadable)
</span><span class="lines">@@ -62,7 +62,7 @@
</span><span class="cx"> "use strict";
</span><span class="cx">
</span><span class="cx"> if (!@isReadableStreamController(this))
</span><del>- throw new @TypeError("Function should be called on a ReadableStreamController");
</del><ins>+ throw @makeThisTypeError("ReadableStreamController", "close");
</ins><span class="cx">
</span><span class="cx"> const stream = this.@controlledReadableStream;
</span><span class="cx"> if (stream.@closeRequested)
</span><span class="lines">@@ -79,7 +79,7 @@
</span><span class="cx"> "use strict";
</span><span class="cx">
</span><span class="cx"> if (!@isReadableStreamController(this))
</span><del>- throw new @TypeError("Function should be called on a ReadableStreamController");
</del><ins>+ throw @makeGetterTypeError("ReadableStreamController", "desiredSize");
</ins><span class="cx">
</span><span class="cx"> return @getReadableStreamDesiredSize(this.@controlledReadableStream);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsReadableStreamReaderjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamReader.js (203765 => 203766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/ReadableStreamReader.js        2016-07-27 06:35:30 UTC (rev 203765)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamReader.js        2016-07-27 06:37:49 UTC (rev 203766)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> "use strict";
</span><span class="cx">
</span><span class="cx"> if (!@isReadableStreamReader(this))
</span><del>- return @Promise.@reject(new @TypeError("Function should be called on a ReadableStreamReader"));
</del><ins>+ return @Promise.@reject(@makeThisTypeError("ReadableStreamReader", "cancel"));
</ins><span class="cx">
</span><span class="cx"> if (!this.@ownerReadableStream)
</span><span class="cx"> return @Promise.@reject(new @TypeError("cancel() called on a reader owned by no readable stream"));
</span><span class="lines">@@ -43,7 +43,7 @@
</span><span class="cx"> "use strict";
</span><span class="cx">
</span><span class="cx"> if (!@isReadableStreamReader(this))
</span><del>- return @Promise.@reject(new @TypeError("Function should be called on a ReadableStreamReader"));
</del><ins>+ return @Promise.@reject(@makeThisTypeError("ReadableStreamReader", "read"));
</ins><span class="cx"> if (!this.@ownerReadableStream)
</span><span class="cx"> return @Promise.@reject(new @TypeError("read() called on a reader owned by no readable stream"));
</span><span class="cx">
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx"> "use strict";
</span><span class="cx">
</span><span class="cx"> if (!@isReadableStreamReader(this))
</span><del>- throw new @TypeError("Function should be called on a ReadableStreamReader");
</del><ins>+ throw @makeThisTypeError("ReadableStreamReader", "releaseLock");
</ins><span class="cx">
</span><span class="cx"> const stream = this.@ownerReadableStream;
</span><span class="cx"> if (!stream)
</span><span class="lines">@@ -78,7 +78,7 @@
</span><span class="cx"> "use strict";
</span><span class="cx">
</span><span class="cx"> if (!@isReadableStreamReader(this))
</span><del>- return @Promise.@reject(new @TypeError("Callee of closed is not a ReadableStreamReader"));
</del><ins>+ return @Promise.@reject(@makeGetterTypeError("ReadableStreamReader", "closed"));
</ins><span class="cx">
</span><span class="cx"> return this.@closedPromiseCapability.@promise;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMBindingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp (203765 => 203766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp        2016-07-27 06:35:30 UTC (rev 203765)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp        2016-07-27 06:37:49 UTC (rev 203766)
</span><span class="lines">@@ -833,11 +833,6 @@
</span><span class="cx"> return throwVMError(&state, createReferenceError(&state, makeString(interfaceName, " constructor associated document is unavailable")));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-JSC::EncodedJSValue throwGetterTypeError(JSC::ExecState& state, const char* interfaceName, const char* attributeName)
-{
- return throwVMTypeError(&state, makeString("The ", interfaceName, '.', attributeName, " getter can only be used on instances of ", interfaceName));
-}
-
</del><span class="cx"> void throwSequenceTypeError(JSC::ExecState& state)
</span><span class="cx"> {
</span><span class="cx"> throwTypeError(state, ASCIILiteral("Value is not a sequence"));
</span><span class="lines">@@ -848,6 +843,16 @@
</span><span class="cx"> throwTypeError(&state, ASCIILiteral("The provided value is non-finite"));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+String makeGetterTypeErrorMessage(const char* interfaceName, const char* attributeName)
+{
+ return makeString("The ", interfaceName, '.', attributeName, " getter can only be used on instances of ", interfaceName);
+}
+
+JSC::EncodedJSValue throwGetterTypeError(JSC::ExecState& state, const char* interfaceName, const char* attributeName)
+{
+ return throwVMTypeError(&state, makeGetterTypeErrorMessage(interfaceName, attributeName));
+}
+
</ins><span class="cx"> bool throwSetterTypeError(JSC::ExecState& state, const char* interfaceName, const char* attributeName)
</span><span class="cx"> {
</span><span class="cx"> throwTypeError(state, makeString("The ", interfaceName, '.', attributeName, " setter can only be used on instances of ", interfaceName));
</span><span class="lines">@@ -854,9 +859,14 @@
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+String makeThisTypeErrorMessage(const char* interfaceName, const char* functionName)
+{
+ return makeString("Can only call ", interfaceName, '.', functionName, " on instances of ", interfaceName);
+}
+
</ins><span class="cx"> EncodedJSValue throwThisTypeError(JSC::ExecState& state, const char* interfaceName, const char* functionName)
</span><span class="cx"> {
</span><del>- return throwVMTypeError(&state, makeString("Can only call ", interfaceName, '.', functionName, " on instances of ", interfaceName));
</del><ins>+ return throwTypeError(state, makeThisTypeErrorMessage(interfaceName, functionName));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void callFunctionWithCurrentArguments(JSC::ExecState& state, JSC::JSObject& thisObject, JSC::JSFunction& function)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMBindingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (203765 => 203766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2016-07-27 06:35:30 UTC (rev 203765)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h        2016-07-27 06:37:49 UTC (rev 203766)
</span><span class="lines">@@ -125,6 +125,9 @@
</span><span class="cx"> JSC::EncodedJSValue throwArgumentMustBeFunctionError(JSC::ExecState&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName);
</span><span class="cx"> WEBCORE_EXPORT JSC::EncodedJSValue throwArgumentTypeError(JSC::ExecState&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedType);
</span><span class="cx"> JSC::EncodedJSValue throwConstructorDocumentUnavailableError(JSC::ExecState&, const char* interfaceName);
</span><ins>+
+String makeGetterTypeErrorMessage(const char* interfaceName, const char* attributeName);
+String makeThisTypeErrorMessage(const char* interfaceName, const char* attributeName);
</ins><span class="cx"> WEBCORE_EXPORT JSC::EncodedJSValue throwGetterTypeError(JSC::ExecState&, const char* interfaceName, const char* attributeName);
</span><span class="cx"> WEBCORE_EXPORT JSC::EncodedJSValue throwThisTypeError(JSC::ExecState&, const char* interfaceName, const char* functionName);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp (203765 => 203766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp        2016-07-27 06:35:30 UTC (rev 203765)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp        2016-07-27 06:37:49 UTC (rev 203766)
</span><span class="lines">@@ -45,6 +45,9 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+EncodedJSValue JSC_HOST_CALL makeThisTypeErrorForBuiltins(ExecState*);
+EncodedJSValue JSC_HOST_CALL makeGetterTypeErrorForBuiltins(ExecState*);
+
</ins><span class="cx"> const ClassInfo JSDOMGlobalObject::s_info = { "DOMGlobalObject", &JSGlobalObject::s_info, 0, CREATE_METHOD_TABLE(JSDOMGlobalObject) };
</span><span class="cx">
</span><span class="cx"> JSDOMGlobalObject::JSDOMGlobalObject(VM& vm, Structure* structure, Ref<DOMWrapperWorld>&& world, const GlobalObjectMethodTable* globalObjectMethodTable)
</span><span class="lines">@@ -61,6 +64,30 @@
</span><span class="cx"> static_cast<JSDOMGlobalObject*>(cell)->JSDOMGlobalObject::~JSDOMGlobalObject();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+EncodedJSValue JSC_HOST_CALL makeThisTypeErrorForBuiltins(ExecState* execState)
+{
+ ASSERT(execState);
+ ASSERT(execState->argumentCount() == 2);
+
+ auto interfaceName = execState->uncheckedArgument(0).getString(execState);
+ ASSERT(!execState->hadException());
+ auto functionName = execState->uncheckedArgument(1).getString(execState);
+ ASSERT(!execState->hadException());
+ return JSValue::encode(createTypeError(execState, makeThisTypeErrorMessage(interfaceName.utf8().data(), functionName.utf8().data())));
+}
+
+EncodedJSValue JSC_HOST_CALL makeGetterTypeErrorForBuiltins(ExecState* execState)
+{
+ ASSERT(execState);
+ ASSERT(execState->argumentCount() == 2);
+
+ auto interfaceName = execState->uncheckedArgument(0).getString(execState);
+ ASSERT(!execState->hadException());
+ auto attributeName = execState->uncheckedArgument(1).getString(execState);
+ ASSERT(!execState->hadException());
+ return JSValue::encode(createTypeError(execState, makeGetterTypeErrorMessage(interfaceName.utf8().data(), attributeName.utf8().data())));
+}
+
</ins><span class="cx"> void JSDOMGlobalObject::addBuiltinGlobals(VM& vm)
</span><span class="cx"> {
</span><span class="cx"> m_builtinInternalFunctions.initialize(*this);
</span><span class="lines">@@ -74,9 +101,15 @@
</span><span class="cx"> JSC::WriteBarrier<JSC::JSObject> temp;
</span><span class="cx"> constructors().add(privateReadableStreamControllerConstructor->info(), temp).iterator->value.set(vm, this, privateReadableStreamControllerConstructor);
</span><span class="cx"> constructors().add(privateReadableStreamReaderConstructor->info(), temp).iterator->value.set(vm, this, privateReadableStreamReaderConstructor);
</span><ins>+#endif
</ins><span class="cx">
</span><span class="cx"> JSVMClientData& clientData = *static_cast<JSVMClientData*>(vm.clientData);
</span><span class="cx"> JSDOMGlobalObject::GlobalPropertyInfo staticGlobals[] = {
</span><ins>+ JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().makeThisTypeErrorPrivateName(),
+ JSFunction::create(vm, this, 2, String(), makeThisTypeErrorForBuiltins), DontDelete | ReadOnly),
+ JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().makeGetterTypeErrorPrivateName(),
+ JSFunction::create(vm, this, 2, String(), makeGetterTypeErrorForBuiltins), DontDelete | ReadOnly),
+#if ENABLE(STREAMS_API)
</ins><span class="cx"> JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamClosedPrivateName(), jsNumber(1), DontDelete | ReadOnly),
</span><span class="cx"> JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamClosingPrivateName(), jsNumber(2), DontDelete | ReadOnly),
</span><span class="cx"> JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamErroredPrivateName(), jsNumber(3), DontDelete | ReadOnly),
</span><span class="lines">@@ -85,11 +118,9 @@
</span><span class="cx"> JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().streamWritablePrivateName(), jsNumber(6), DontDelete | ReadOnly),
</span><span class="cx"> JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().ReadableStreamControllerPrivateName(), privateReadableStreamControllerConstructor, DontDelete | ReadOnly),
</span><span class="cx"> JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().ReadableStreamReaderPrivateName(), privateReadableStreamReaderConstructor, DontDelete | ReadOnly),
</span><ins>+#endif
</ins><span class="cx"> };
</span><span class="cx"> addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
</span><del>-#else
- UNUSED_PARAM(vm);
-#endif
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void JSDOMGlobalObject::finishCreation(VM& vm)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsWebCoreBuiltinNamesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (203765 => 203766)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h        2016-07-27 06:35:30 UTC (rev 203765)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h        2016-07-27 06:37:49 UTC (rev 203766)
</span><span class="lines">@@ -51,6 +51,8 @@
</span><span class="cx"> macro(initializeWith) \
</span><span class="cx"> macro(isDisturbed) \
</span><span class="cx"> macro(localStreams) \
</span><ins>+ macro(makeThisTypeError) \
+ macro(makeGetterTypeError) \
</ins><span class="cx"> macro(operations) \
</span><span class="cx"> macro(ownerReadableStream) \
</span><span class="cx"> macro(privateGetStats) \
</span></span></pre>
</div>
</div>
</body>
</html>