Make console a namespace object (like Math/JSON), allowing functions to be called unbound
https://bugs.webkit.org/show_bug.cgi?id=157286
<rdar://problem/26052830>
Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-05-02
Reviewed by Timothy Hatcher.
Source/JavaScriptCore:
This changes `console` to be a global namespace object, like `Math` and `JSON`.
It just holds a bunch of functions, that can be used on their own, unbound.
For example, `[1,2,3].forEach(console.log)` and `var log = console.log; log(1)`
used to throw exceptions and now do not.
Previously console was an Object/Prototype pair, so functions were on
ConsolePrototype (console.__proto__.log) and they needed to be called
Console objects as the `this` value. Now, `console` is just a standard
object with a bunch of functions. Since there is no console prototype the
functions can be passed around and called as expected and they will
just do the right thing.
For compatability with other browsers, `console` was made enumerable
on the global object.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
Add new files and remove old files.
* runtime/CommonIdentifiers.h:
Add "console".
* runtime/ConsoleObject.cpp: Renamed from Source/JavaScriptCore/runtime/ConsolePrototype.cpp.
(JSC::ConsoleObject::ConsoleObject):
(JSC::ConsoleObject::finishCreation):
(JSC::valueToStringWithUndefinedOrNullCheck):
(JSC::consoleLogWithLevel):
(JSC::consoleProtoFuncDebug):
(JSC::consoleProtoFuncError):
(JSC::consoleProtoFuncLog):
(JSC::consoleProtoFuncInfo):
(JSC::consoleProtoFuncWarn):
(JSC::consoleProtoFuncClear):
(JSC::consoleProtoFuncDir):
(JSC::consoleProtoFuncDirXML):
(JSC::consoleProtoFuncTable):
(JSC::consoleProtoFuncTrace):
(JSC::consoleProtoFuncAssert):
(JSC::consoleProtoFuncCount):
(JSC::consoleProtoFuncProfile):
(JSC::consoleProtoFuncProfileEnd):
(JSC::consoleProtoFuncTakeHeapSnapshot):
(JSC::consoleProtoFuncTime):
(JSC::consoleProtoFuncTimeEnd):
(JSC::consoleProtoFuncTimeStamp):
(JSC::consoleProtoFuncGroup):
(JSC::consoleProtoFuncGroupCollapsed):
(JSC::consoleProtoFuncGroupEnd):
Console functions no longer need to check if the this object is
a Console object. They will always just work now.
* runtime/MathObject.cpp:
* runtime/MathObject.h:
* runtime/ConsoleObject.h: Renamed from Source/JavaScriptCore/runtime/ConsolePrototype.h.
(JSC::ConsoleObject::create):
(JSC::ConsoleObject::createStructure):
ConsoleObject is a basic object like MathObject.
* runtime/JSConsole.cpp: Removed.
* runtime/JSConsole.h: Removed.
* runtime/JSGlobalObject.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
Remove JSConsole / ConsolePrototype in favor of the single ConsoleObject.
LayoutTests:
* js/console-expected.txt: Added.
* js/console.html: Added.
Canonical link: https://commits.webkit.org/175386@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200350 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-03 00:51:24 +00:00
|
|
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<script src="../resources/js-test-pre.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<script>
|
|
|
|
shouldBeEqualToString("typeof console", "object");
|
2020-08-22 18:08:49 +00:00
|
|
|
shouldBeEqualToString("console.toString()", "[object console]");
|
Make console a namespace object (like Math/JSON), allowing functions to be called unbound
https://bugs.webkit.org/show_bug.cgi?id=157286
<rdar://problem/26052830>
Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-05-02
Reviewed by Timothy Hatcher.
Source/JavaScriptCore:
This changes `console` to be a global namespace object, like `Math` and `JSON`.
It just holds a bunch of functions, that can be used on their own, unbound.
For example, `[1,2,3].forEach(console.log)` and `var log = console.log; log(1)`
used to throw exceptions and now do not.
Previously console was an Object/Prototype pair, so functions were on
ConsolePrototype (console.__proto__.log) and they needed to be called
Console objects as the `this` value. Now, `console` is just a standard
object with a bunch of functions. Since there is no console prototype the
functions can be passed around and called as expected and they will
just do the right thing.
For compatability with other browsers, `console` was made enumerable
on the global object.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
Add new files and remove old files.
* runtime/CommonIdentifiers.h:
Add "console".
* runtime/ConsoleObject.cpp: Renamed from Source/JavaScriptCore/runtime/ConsolePrototype.cpp.
(JSC::ConsoleObject::ConsoleObject):
(JSC::ConsoleObject::finishCreation):
(JSC::valueToStringWithUndefinedOrNullCheck):
(JSC::consoleLogWithLevel):
(JSC::consoleProtoFuncDebug):
(JSC::consoleProtoFuncError):
(JSC::consoleProtoFuncLog):
(JSC::consoleProtoFuncInfo):
(JSC::consoleProtoFuncWarn):
(JSC::consoleProtoFuncClear):
(JSC::consoleProtoFuncDir):
(JSC::consoleProtoFuncDirXML):
(JSC::consoleProtoFuncTable):
(JSC::consoleProtoFuncTrace):
(JSC::consoleProtoFuncAssert):
(JSC::consoleProtoFuncCount):
(JSC::consoleProtoFuncProfile):
(JSC::consoleProtoFuncProfileEnd):
(JSC::consoleProtoFuncTakeHeapSnapshot):
(JSC::consoleProtoFuncTime):
(JSC::consoleProtoFuncTimeEnd):
(JSC::consoleProtoFuncTimeStamp):
(JSC::consoleProtoFuncGroup):
(JSC::consoleProtoFuncGroupCollapsed):
(JSC::consoleProtoFuncGroupEnd):
Console functions no longer need to check if the this object is
a Console object. They will always just work now.
* runtime/MathObject.cpp:
* runtime/MathObject.h:
* runtime/ConsoleObject.h: Renamed from Source/JavaScriptCore/runtime/ConsolePrototype.h.
(JSC::ConsoleObject::create):
(JSC::ConsoleObject::createStructure):
ConsoleObject is a basic object like MathObject.
* runtime/JSConsole.cpp: Removed.
* runtime/JSConsole.h: Removed.
* runtime/JSGlobalObject.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
Remove JSConsole / ConsolePrototype in favor of the single ConsoleObject.
LayoutTests:
* js/console-expected.txt: Added.
* js/console.html: Added.
Canonical link: https://commits.webkit.org/175386@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200350 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-03 00:51:24 +00:00
|
|
|
shouldBe("console", "console");
|
|
|
|
|
2016-05-17 18:20:26 +00:00
|
|
|
// <https://webkit.org/b/157782> console namespace breaks putting properties on console.__proto__
|
|
|
|
shouldNotBe("Object.getPrototypeOf(console)", "Object.getPrototypeOf({})");
|
|
|
|
|
Make console a namespace object (like Math/JSON), allowing functions to be called unbound
https://bugs.webkit.org/show_bug.cgi?id=157286
<rdar://problem/26052830>
Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-05-02
Reviewed by Timothy Hatcher.
Source/JavaScriptCore:
This changes `console` to be a global namespace object, like `Math` and `JSON`.
It just holds a bunch of functions, that can be used on their own, unbound.
For example, `[1,2,3].forEach(console.log)` and `var log = console.log; log(1)`
used to throw exceptions and now do not.
Previously console was an Object/Prototype pair, so functions were on
ConsolePrototype (console.__proto__.log) and they needed to be called
Console objects as the `this` value. Now, `console` is just a standard
object with a bunch of functions. Since there is no console prototype the
functions can be passed around and called as expected and they will
just do the right thing.
For compatability with other browsers, `console` was made enumerable
on the global object.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
Add new files and remove old files.
* runtime/CommonIdentifiers.h:
Add "console".
* runtime/ConsoleObject.cpp: Renamed from Source/JavaScriptCore/runtime/ConsolePrototype.cpp.
(JSC::ConsoleObject::ConsoleObject):
(JSC::ConsoleObject::finishCreation):
(JSC::valueToStringWithUndefinedOrNullCheck):
(JSC::consoleLogWithLevel):
(JSC::consoleProtoFuncDebug):
(JSC::consoleProtoFuncError):
(JSC::consoleProtoFuncLog):
(JSC::consoleProtoFuncInfo):
(JSC::consoleProtoFuncWarn):
(JSC::consoleProtoFuncClear):
(JSC::consoleProtoFuncDir):
(JSC::consoleProtoFuncDirXML):
(JSC::consoleProtoFuncTable):
(JSC::consoleProtoFuncTrace):
(JSC::consoleProtoFuncAssert):
(JSC::consoleProtoFuncCount):
(JSC::consoleProtoFuncProfile):
(JSC::consoleProtoFuncProfileEnd):
(JSC::consoleProtoFuncTakeHeapSnapshot):
(JSC::consoleProtoFuncTime):
(JSC::consoleProtoFuncTimeEnd):
(JSC::consoleProtoFuncTimeStamp):
(JSC::consoleProtoFuncGroup):
(JSC::consoleProtoFuncGroupCollapsed):
(JSC::consoleProtoFuncGroupEnd):
Console functions no longer need to check if the this object is
a Console object. They will always just work now.
* runtime/MathObject.cpp:
* runtime/MathObject.h:
* runtime/ConsoleObject.h: Renamed from Source/JavaScriptCore/runtime/ConsolePrototype.h.
(JSC::ConsoleObject::create):
(JSC::ConsoleObject::createStructure):
ConsoleObject is a basic object like MathObject.
* runtime/JSConsole.cpp: Removed.
* runtime/JSConsole.h: Removed.
* runtime/JSGlobalObject.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
Remove JSConsole / ConsolePrototype in favor of the single ConsoleObject.
LayoutTests:
* js/console-expected.txt: Added.
* js/console.html: Added.
Canonical link: https://commits.webkit.org/175386@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200350 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-03 00:51:24 +00:00
|
|
|
var consoleDescriptor = Object.getOwnPropertyDescriptor(window, "console");
|
|
|
|
shouldBeTrue('consoleDescriptor.configurable');
|
|
|
|
shouldBeTrue('consoleDescriptor.writable');
|
2016-05-03 09:18:40 +00:00
|
|
|
shouldBeFalse('consoleDescriptor.enumerable');
|
Make console a namespace object (like Math/JSON), allowing functions to be called unbound
https://bugs.webkit.org/show_bug.cgi?id=157286
<rdar://problem/26052830>
Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-05-02
Reviewed by Timothy Hatcher.
Source/JavaScriptCore:
This changes `console` to be a global namespace object, like `Math` and `JSON`.
It just holds a bunch of functions, that can be used on their own, unbound.
For example, `[1,2,3].forEach(console.log)` and `var log = console.log; log(1)`
used to throw exceptions and now do not.
Previously console was an Object/Prototype pair, so functions were on
ConsolePrototype (console.__proto__.log) and they needed to be called
Console objects as the `this` value. Now, `console` is just a standard
object with a bunch of functions. Since there is no console prototype the
functions can be passed around and called as expected and they will
just do the right thing.
For compatability with other browsers, `console` was made enumerable
on the global object.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
Add new files and remove old files.
* runtime/CommonIdentifiers.h:
Add "console".
* runtime/ConsoleObject.cpp: Renamed from Source/JavaScriptCore/runtime/ConsolePrototype.cpp.
(JSC::ConsoleObject::ConsoleObject):
(JSC::ConsoleObject::finishCreation):
(JSC::valueToStringWithUndefinedOrNullCheck):
(JSC::consoleLogWithLevel):
(JSC::consoleProtoFuncDebug):
(JSC::consoleProtoFuncError):
(JSC::consoleProtoFuncLog):
(JSC::consoleProtoFuncInfo):
(JSC::consoleProtoFuncWarn):
(JSC::consoleProtoFuncClear):
(JSC::consoleProtoFuncDir):
(JSC::consoleProtoFuncDirXML):
(JSC::consoleProtoFuncTable):
(JSC::consoleProtoFuncTrace):
(JSC::consoleProtoFuncAssert):
(JSC::consoleProtoFuncCount):
(JSC::consoleProtoFuncProfile):
(JSC::consoleProtoFuncProfileEnd):
(JSC::consoleProtoFuncTakeHeapSnapshot):
(JSC::consoleProtoFuncTime):
(JSC::consoleProtoFuncTimeEnd):
(JSC::consoleProtoFuncTimeStamp):
(JSC::consoleProtoFuncGroup):
(JSC::consoleProtoFuncGroupCollapsed):
(JSC::consoleProtoFuncGroupEnd):
Console functions no longer need to check if the this object is
a Console object. They will always just work now.
* runtime/MathObject.cpp:
* runtime/MathObject.h:
* runtime/ConsoleObject.h: Renamed from Source/JavaScriptCore/runtime/ConsolePrototype.h.
(JSC::ConsoleObject::create):
(JSC::ConsoleObject::createStructure):
ConsoleObject is a basic object like MathObject.
* runtime/JSConsole.cpp: Removed.
* runtime/JSConsole.h: Removed.
* runtime/JSGlobalObject.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
Remove JSConsole / ConsolePrototype in favor of the single ConsoleObject.
LayoutTests:
* js/console-expected.txt: Added.
* js/console.html: Added.
Canonical link: https://commits.webkit.org/175386@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200350 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-03 00:51:24 +00:00
|
|
|
|
|
|
|
// Console methods don't care what their this object is.
|
|
|
|
console.log("log message");
|
|
|
|
console.log.call(null, "log message");
|
|
|
|
console.log.call(undefined, "log message");
|
|
|
|
console.log.call(console, "log message");
|
|
|
|
console.log.call(123, "log message");
|
|
|
|
console.log.call("ignore", "log message");
|
|
|
|
console.log.bind(console, "log message");
|
|
|
|
console.log.bind(console)("log message");
|
|
|
|
[1,2,3].forEach(console.log);
|
|
|
|
|
|
|
|
// All properties should be enumerable.
|
|
|
|
var property, descriptor;
|
|
|
|
var enumerablePropertyCount = 0;
|
|
|
|
for (property in console) {
|
|
|
|
enumerablePropertyCount++;
|
|
|
|
descriptor = Object.getOwnPropertyDescriptor(console, property);
|
|
|
|
|
|
|
|
debug("");
|
|
|
|
debug(`console.${property}`);
|
|
|
|
shouldBeEqualToString(`typeof console.${property}`, "function");
|
|
|
|
shouldBe(`console.${property}.length`, '0');
|
|
|
|
shouldBeTrue('descriptor.configurable');
|
|
|
|
shouldBeTrue('descriptor.writable');
|
|
|
|
shouldBeTrue('descriptor.enumerable');
|
|
|
|
}
|
|
|
|
|
|
|
|
debug("");
|
|
|
|
shouldBe("Object.getOwnPropertyNames(console).length", "enumerablePropertyCount");
|
2017-12-04 21:40:55 +00:00
|
|
|
|
Web Inspector: provide a way to capture a screenshot of a node from within the page
https://bugs.webkit.org/show_bug.cgi?id=194279
<rdar://problem/10731573>
Reviewed by Joseph Pecoraro.
Source/JavaScriptCore:
Add `console.screenshot` functionality, which displays a screenshot of a given object (if
able) within Web Inspector's Console tab. From there, it can be viewed and saved.
Currently, `console.screenshot` will
- capture an image of a `Node` (if provided)
- capture an image of the viewport if nothing is provided
* inspector/protocol/Console.json:
Add `Image` enum value to `ConsoleMessage` type.
* runtime/ConsoleTypes.h:
* inspector/ConsoleMessage.h:
* inspector/ConsoleMessage.cpp:
(Inspector::messageTypeValue):
* runtime/ConsoleClient.h:
* runtime/ConsoleObject.cpp:
(JSC::ConsoleObject::finishCreation):
(JSC::consoleProtoFuncScreenshot): Added.
* inspector/JSGlobalObjectConsoleClient.h:
* inspector/JSGlobalObjectConsoleClient.cpp:
(Inspector::JSGlobalObjectConsoleClient::screenshot): Added.
Source/WebCore:
Test: inspector/console/console-screenshot.html
Add `console.screenshot` functionality, which displays a screenshot of a given object (if
able) within Web Inspector's Console tab. From there, it can be viewed and saved.
Currently, `console.screenshot` will
- capture an image of a `Node` (if provided)
- capture an image of the viewport if nothing is provided
* page/PageConsoleClient.h:
* page/PageConsoleClient.cpp:
(WebCore::PageConsoleClient::addMessage):
(WebCore::PageConsoleClient::screenshot): Added.
* workers/WorkerConsoleClient.h:
* workers/WorkerConsoleClient.cpp:
(WebCore::WorkerConsoleClient::screenshot): Added.
* worklets/WorkletConsoleClient.h:
* worklets/WorkletConsoleClient.cpp:
(WebCore::WorkletConsoleClient::screenshot): Added.
* inspector/CommandLineAPIModuleSource.js:
(CommandLineAPIImpl.prototype.screenshot): Added.
* inspector/InspectorInstrumentation.h:
Source/WebInspectorUI:
Add `console.screenshot` functionality, which displays a screenshot of a given object (if
able) within Web Inspector's Console tab. From there, it can be viewed and saved.
Currently, `console.screenshot` will
- capture an image of a `Node` (if provided)
- capture an image of the viewport if nothing is provided
* UserInterface/Models/ConsoleMessage.js:
(WI.ConsoleMessage):
* UserInterface/Views/ConsoleCommandView.js:
(WI.ConsoleCommandView.prototype.render):
* UserInterface/Views/ConsoleMessageView.js:
(WI.ConsoleMessageView.prototype.render):
(WI.ConsoleMessageView.prototype.toClipboardString):
(WI.ConsoleMessageView.prototype._appendMessageTextAndArguments):
(WI.ConsoleMessageView.prototype._appendSavedResultIndex):
(WI.ConsoleMessageView.prototype._appendStackTrace):
(WI.ConsoleMessageView.prototype._makeExpandable):
(WI.ConsoleMessageView.prototype._handleContextMenu): Added.
* UserInterface/Views/ConsoleMessageView.css:
(.console-user-command.special-user-log > .console-message-body): Added.
(.console-message-body): Added.
(.console-message-body > span): Added.
(.console-message-body > span > :matches(.console-message-enclosed, .console-message-preview, .console-message-preview-divider)): Added.
(.console-message-body > .console-image): Added.
(.console-message-body > .show-grid): Added.
(.console-error-level .console-message-body): Added.
(.console-warning-level .console-message-body): Added.
(.console-log-level.console-image-container::before): Added.
(.console-user-command > .console-message-body): Added.
(.console-warning-level .console-message-body): Added.
(.console-error-level .console-message-body): Added.
(.console-user-command > .console-message-body): Added.
(.console-user-command.special-user-log > .console-message-text): Deleted.
(.console-message-text): Deleted.
(.console-message-text > span): Deleted.
(.console-message-text > span > :matches(.console-message-enclosed, .console-message-preview, .console-message-preview-divider)): Deleted.
(.console-error-level .console-message-text): Deleted.
(.console-warning-level .console-message-text): Deleted.
(.console-user-command > .console-message-text): Deleted.
(.console-warning-level .console-message-text): Deleted.
(.console-error-level .console-message-text): Deleted.
(.console-user-command > .console-message-text): Deleted.
* UserInterface/Views/LogContentView.css:
(.search-in-progress .console-item:not(.filtered-out-by-search).special-user-log .console-message-text .highlighted): Added.
(.search-in-progress .console-item:not(.filtered-out-by-search).special-user-log .console-message-body .highlighted): Deleted.
Renamed variables/classes to be more semantically correct when the content is an image.
- `_messageTextElement` to `_messageBodyElement` (JS)
- `.console-message-text` to `.console-message-body` (CSS)
* UserInterface/Controllers/JavaScriptLogViewController.js:
(WI.JavaScriptLogViewController.prototype.renderPendingMessages):
* UserInterface/Views/Main.css:
(:matches(img, canvas).show-grid):
(@media (prefers-color-scheme: dark) :matches(img, canvas).show-grid):
* UserInterface/Base/FileUtilities.js:
(WI.FileUtilities.screenshotString): Added.
* UserInterface/Models/NativeFunctionParameters.js:
* UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js:
* UserInterface/Images/ConsoleImage.svg: Copied from UserInterface/Images/Canvas.svg.
* Localizations/en.lproj/localizedStrings.js:
LayoutTests:
* js/console.html:
* js/console-expected.txt:
* inspector/console/console-screenshot.html: Added.
* inspector/console/console-screenshot-expected.txt: Added.
* http/tests/inspector/dom/cross-domain-inspected-node-access-expected.txt:
Canonical link: https://commits.webkit.org/210079@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242992 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-15 08:12:21 +00:00
|
|
|
const fuzzingArguments = [
|
2017-12-04 21:40:55 +00:00
|
|
|
`undefined`,
|
|
|
|
`null`,
|
|
|
|
`1`,
|
|
|
|
`"test"`,
|
|
|
|
`[]`,
|
|
|
|
`{}`,
|
|
|
|
`window`,
|
|
|
|
`console`,
|
|
|
|
];
|
|
|
|
|
|
|
|
debug("");
|
|
|
|
debug("fuzzing of target for console.record");
|
|
|
|
shouldNotThrow(`console.record()`);
|
Web Inspector: provide a way to capture a screenshot of a node from within the page
https://bugs.webkit.org/show_bug.cgi?id=194279
<rdar://problem/10731573>
Reviewed by Joseph Pecoraro.
Source/JavaScriptCore:
Add `console.screenshot` functionality, which displays a screenshot of a given object (if
able) within Web Inspector's Console tab. From there, it can be viewed and saved.
Currently, `console.screenshot` will
- capture an image of a `Node` (if provided)
- capture an image of the viewport if nothing is provided
* inspector/protocol/Console.json:
Add `Image` enum value to `ConsoleMessage` type.
* runtime/ConsoleTypes.h:
* inspector/ConsoleMessage.h:
* inspector/ConsoleMessage.cpp:
(Inspector::messageTypeValue):
* runtime/ConsoleClient.h:
* runtime/ConsoleObject.cpp:
(JSC::ConsoleObject::finishCreation):
(JSC::consoleProtoFuncScreenshot): Added.
* inspector/JSGlobalObjectConsoleClient.h:
* inspector/JSGlobalObjectConsoleClient.cpp:
(Inspector::JSGlobalObjectConsoleClient::screenshot): Added.
Source/WebCore:
Test: inspector/console/console-screenshot.html
Add `console.screenshot` functionality, which displays a screenshot of a given object (if
able) within Web Inspector's Console tab. From there, it can be viewed and saved.
Currently, `console.screenshot` will
- capture an image of a `Node` (if provided)
- capture an image of the viewport if nothing is provided
* page/PageConsoleClient.h:
* page/PageConsoleClient.cpp:
(WebCore::PageConsoleClient::addMessage):
(WebCore::PageConsoleClient::screenshot): Added.
* workers/WorkerConsoleClient.h:
* workers/WorkerConsoleClient.cpp:
(WebCore::WorkerConsoleClient::screenshot): Added.
* worklets/WorkletConsoleClient.h:
* worklets/WorkletConsoleClient.cpp:
(WebCore::WorkletConsoleClient::screenshot): Added.
* inspector/CommandLineAPIModuleSource.js:
(CommandLineAPIImpl.prototype.screenshot): Added.
* inspector/InspectorInstrumentation.h:
Source/WebInspectorUI:
Add `console.screenshot` functionality, which displays a screenshot of a given object (if
able) within Web Inspector's Console tab. From there, it can be viewed and saved.
Currently, `console.screenshot` will
- capture an image of a `Node` (if provided)
- capture an image of the viewport if nothing is provided
* UserInterface/Models/ConsoleMessage.js:
(WI.ConsoleMessage):
* UserInterface/Views/ConsoleCommandView.js:
(WI.ConsoleCommandView.prototype.render):
* UserInterface/Views/ConsoleMessageView.js:
(WI.ConsoleMessageView.prototype.render):
(WI.ConsoleMessageView.prototype.toClipboardString):
(WI.ConsoleMessageView.prototype._appendMessageTextAndArguments):
(WI.ConsoleMessageView.prototype._appendSavedResultIndex):
(WI.ConsoleMessageView.prototype._appendStackTrace):
(WI.ConsoleMessageView.prototype._makeExpandable):
(WI.ConsoleMessageView.prototype._handleContextMenu): Added.
* UserInterface/Views/ConsoleMessageView.css:
(.console-user-command.special-user-log > .console-message-body): Added.
(.console-message-body): Added.
(.console-message-body > span): Added.
(.console-message-body > span > :matches(.console-message-enclosed, .console-message-preview, .console-message-preview-divider)): Added.
(.console-message-body > .console-image): Added.
(.console-message-body > .show-grid): Added.
(.console-error-level .console-message-body): Added.
(.console-warning-level .console-message-body): Added.
(.console-log-level.console-image-container::before): Added.
(.console-user-command > .console-message-body): Added.
(.console-warning-level .console-message-body): Added.
(.console-error-level .console-message-body): Added.
(.console-user-command > .console-message-body): Added.
(.console-user-command.special-user-log > .console-message-text): Deleted.
(.console-message-text): Deleted.
(.console-message-text > span): Deleted.
(.console-message-text > span > :matches(.console-message-enclosed, .console-message-preview, .console-message-preview-divider)): Deleted.
(.console-error-level .console-message-text): Deleted.
(.console-warning-level .console-message-text): Deleted.
(.console-user-command > .console-message-text): Deleted.
(.console-warning-level .console-message-text): Deleted.
(.console-error-level .console-message-text): Deleted.
(.console-user-command > .console-message-text): Deleted.
* UserInterface/Views/LogContentView.css:
(.search-in-progress .console-item:not(.filtered-out-by-search).special-user-log .console-message-text .highlighted): Added.
(.search-in-progress .console-item:not(.filtered-out-by-search).special-user-log .console-message-body .highlighted): Deleted.
Renamed variables/classes to be more semantically correct when the content is an image.
- `_messageTextElement` to `_messageBodyElement` (JS)
- `.console-message-text` to `.console-message-body` (CSS)
* UserInterface/Controllers/JavaScriptLogViewController.js:
(WI.JavaScriptLogViewController.prototype.renderPendingMessages):
* UserInterface/Views/Main.css:
(:matches(img, canvas).show-grid):
(@media (prefers-color-scheme: dark) :matches(img, canvas).show-grid):
* UserInterface/Base/FileUtilities.js:
(WI.FileUtilities.screenshotString): Added.
* UserInterface/Models/NativeFunctionParameters.js:
* UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js:
* UserInterface/Images/ConsoleImage.svg: Copied from UserInterface/Images/Canvas.svg.
* Localizations/en.lproj/localizedStrings.js:
LayoutTests:
* js/console.html:
* js/console-expected.txt:
* inspector/console/console-screenshot.html: Added.
* inspector/console/console-screenshot-expected.txt: Added.
* http/tests/inspector/dom/cross-domain-inspected-node-access-expected.txt:
Canonical link: https://commits.webkit.org/210079@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242992 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-15 08:12:21 +00:00
|
|
|
for (let argument of fuzzingArguments)
|
2017-12-04 21:40:55 +00:00
|
|
|
shouldNotThrow(`console.record(${argument})`);
|
|
|
|
|
|
|
|
debug("");
|
|
|
|
debug("fuzzing of options for console.record");
|
Web Inspector: provide a way to capture a screenshot of a node from within the page
https://bugs.webkit.org/show_bug.cgi?id=194279
<rdar://problem/10731573>
Reviewed by Joseph Pecoraro.
Source/JavaScriptCore:
Add `console.screenshot` functionality, which displays a screenshot of a given object (if
able) within Web Inspector's Console tab. From there, it can be viewed and saved.
Currently, `console.screenshot` will
- capture an image of a `Node` (if provided)
- capture an image of the viewport if nothing is provided
* inspector/protocol/Console.json:
Add `Image` enum value to `ConsoleMessage` type.
* runtime/ConsoleTypes.h:
* inspector/ConsoleMessage.h:
* inspector/ConsoleMessage.cpp:
(Inspector::messageTypeValue):
* runtime/ConsoleClient.h:
* runtime/ConsoleObject.cpp:
(JSC::ConsoleObject::finishCreation):
(JSC::consoleProtoFuncScreenshot): Added.
* inspector/JSGlobalObjectConsoleClient.h:
* inspector/JSGlobalObjectConsoleClient.cpp:
(Inspector::JSGlobalObjectConsoleClient::screenshot): Added.
Source/WebCore:
Test: inspector/console/console-screenshot.html
Add `console.screenshot` functionality, which displays a screenshot of a given object (if
able) within Web Inspector's Console tab. From there, it can be viewed and saved.
Currently, `console.screenshot` will
- capture an image of a `Node` (if provided)
- capture an image of the viewport if nothing is provided
* page/PageConsoleClient.h:
* page/PageConsoleClient.cpp:
(WebCore::PageConsoleClient::addMessage):
(WebCore::PageConsoleClient::screenshot): Added.
* workers/WorkerConsoleClient.h:
* workers/WorkerConsoleClient.cpp:
(WebCore::WorkerConsoleClient::screenshot): Added.
* worklets/WorkletConsoleClient.h:
* worklets/WorkletConsoleClient.cpp:
(WebCore::WorkletConsoleClient::screenshot): Added.
* inspector/CommandLineAPIModuleSource.js:
(CommandLineAPIImpl.prototype.screenshot): Added.
* inspector/InspectorInstrumentation.h:
Source/WebInspectorUI:
Add `console.screenshot` functionality, which displays a screenshot of a given object (if
able) within Web Inspector's Console tab. From there, it can be viewed and saved.
Currently, `console.screenshot` will
- capture an image of a `Node` (if provided)
- capture an image of the viewport if nothing is provided
* UserInterface/Models/ConsoleMessage.js:
(WI.ConsoleMessage):
* UserInterface/Views/ConsoleCommandView.js:
(WI.ConsoleCommandView.prototype.render):
* UserInterface/Views/ConsoleMessageView.js:
(WI.ConsoleMessageView.prototype.render):
(WI.ConsoleMessageView.prototype.toClipboardString):
(WI.ConsoleMessageView.prototype._appendMessageTextAndArguments):
(WI.ConsoleMessageView.prototype._appendSavedResultIndex):
(WI.ConsoleMessageView.prototype._appendStackTrace):
(WI.ConsoleMessageView.prototype._makeExpandable):
(WI.ConsoleMessageView.prototype._handleContextMenu): Added.
* UserInterface/Views/ConsoleMessageView.css:
(.console-user-command.special-user-log > .console-message-body): Added.
(.console-message-body): Added.
(.console-message-body > span): Added.
(.console-message-body > span > :matches(.console-message-enclosed, .console-message-preview, .console-message-preview-divider)): Added.
(.console-message-body > .console-image): Added.
(.console-message-body > .show-grid): Added.
(.console-error-level .console-message-body): Added.
(.console-warning-level .console-message-body): Added.
(.console-log-level.console-image-container::before): Added.
(.console-user-command > .console-message-body): Added.
(.console-warning-level .console-message-body): Added.
(.console-error-level .console-message-body): Added.
(.console-user-command > .console-message-body): Added.
(.console-user-command.special-user-log > .console-message-text): Deleted.
(.console-message-text): Deleted.
(.console-message-text > span): Deleted.
(.console-message-text > span > :matches(.console-message-enclosed, .console-message-preview, .console-message-preview-divider)): Deleted.
(.console-error-level .console-message-text): Deleted.
(.console-warning-level .console-message-text): Deleted.
(.console-user-command > .console-message-text): Deleted.
(.console-warning-level .console-message-text): Deleted.
(.console-error-level .console-message-text): Deleted.
(.console-user-command > .console-message-text): Deleted.
* UserInterface/Views/LogContentView.css:
(.search-in-progress .console-item:not(.filtered-out-by-search).special-user-log .console-message-text .highlighted): Added.
(.search-in-progress .console-item:not(.filtered-out-by-search).special-user-log .console-message-body .highlighted): Deleted.
Renamed variables/classes to be more semantically correct when the content is an image.
- `_messageTextElement` to `_messageBodyElement` (JS)
- `.console-message-text` to `.console-message-body` (CSS)
* UserInterface/Controllers/JavaScriptLogViewController.js:
(WI.JavaScriptLogViewController.prototype.renderPendingMessages):
* UserInterface/Views/Main.css:
(:matches(img, canvas).show-grid):
(@media (prefers-color-scheme: dark) :matches(img, canvas).show-grid):
* UserInterface/Base/FileUtilities.js:
(WI.FileUtilities.screenshotString): Added.
* UserInterface/Models/NativeFunctionParameters.js:
* UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js:
* UserInterface/Images/ConsoleImage.svg: Copied from UserInterface/Images/Canvas.svg.
* Localizations/en.lproj/localizedStrings.js:
LayoutTests:
* js/console.html:
* js/console-expected.txt:
* inspector/console/console-screenshot.html: Added.
* inspector/console/console-screenshot-expected.txt: Added.
* http/tests/inspector/dom/cross-domain-inspected-node-access-expected.txt:
Canonical link: https://commits.webkit.org/210079@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242992 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-15 08:12:21 +00:00
|
|
|
for (let argument of fuzzingArguments)
|
2017-12-04 21:40:55 +00:00
|
|
|
shouldNotThrow(`console.record({}, ${argument})`);
|
|
|
|
|
|
|
|
debug("");
|
|
|
|
debug("fuzzing of target for console.recordEnd");
|
|
|
|
shouldNotThrow(`console.recordEnd()`);
|
Web Inspector: provide a way to capture a screenshot of a node from within the page
https://bugs.webkit.org/show_bug.cgi?id=194279
<rdar://problem/10731573>
Reviewed by Joseph Pecoraro.
Source/JavaScriptCore:
Add `console.screenshot` functionality, which displays a screenshot of a given object (if
able) within Web Inspector's Console tab. From there, it can be viewed and saved.
Currently, `console.screenshot` will
- capture an image of a `Node` (if provided)
- capture an image of the viewport if nothing is provided
* inspector/protocol/Console.json:
Add `Image` enum value to `ConsoleMessage` type.
* runtime/ConsoleTypes.h:
* inspector/ConsoleMessage.h:
* inspector/ConsoleMessage.cpp:
(Inspector::messageTypeValue):
* runtime/ConsoleClient.h:
* runtime/ConsoleObject.cpp:
(JSC::ConsoleObject::finishCreation):
(JSC::consoleProtoFuncScreenshot): Added.
* inspector/JSGlobalObjectConsoleClient.h:
* inspector/JSGlobalObjectConsoleClient.cpp:
(Inspector::JSGlobalObjectConsoleClient::screenshot): Added.
Source/WebCore:
Test: inspector/console/console-screenshot.html
Add `console.screenshot` functionality, which displays a screenshot of a given object (if
able) within Web Inspector's Console tab. From there, it can be viewed and saved.
Currently, `console.screenshot` will
- capture an image of a `Node` (if provided)
- capture an image of the viewport if nothing is provided
* page/PageConsoleClient.h:
* page/PageConsoleClient.cpp:
(WebCore::PageConsoleClient::addMessage):
(WebCore::PageConsoleClient::screenshot): Added.
* workers/WorkerConsoleClient.h:
* workers/WorkerConsoleClient.cpp:
(WebCore::WorkerConsoleClient::screenshot): Added.
* worklets/WorkletConsoleClient.h:
* worklets/WorkletConsoleClient.cpp:
(WebCore::WorkletConsoleClient::screenshot): Added.
* inspector/CommandLineAPIModuleSource.js:
(CommandLineAPIImpl.prototype.screenshot): Added.
* inspector/InspectorInstrumentation.h:
Source/WebInspectorUI:
Add `console.screenshot` functionality, which displays a screenshot of a given object (if
able) within Web Inspector's Console tab. From there, it can be viewed and saved.
Currently, `console.screenshot` will
- capture an image of a `Node` (if provided)
- capture an image of the viewport if nothing is provided
* UserInterface/Models/ConsoleMessage.js:
(WI.ConsoleMessage):
* UserInterface/Views/ConsoleCommandView.js:
(WI.ConsoleCommandView.prototype.render):
* UserInterface/Views/ConsoleMessageView.js:
(WI.ConsoleMessageView.prototype.render):
(WI.ConsoleMessageView.prototype.toClipboardString):
(WI.ConsoleMessageView.prototype._appendMessageTextAndArguments):
(WI.ConsoleMessageView.prototype._appendSavedResultIndex):
(WI.ConsoleMessageView.prototype._appendStackTrace):
(WI.ConsoleMessageView.prototype._makeExpandable):
(WI.ConsoleMessageView.prototype._handleContextMenu): Added.
* UserInterface/Views/ConsoleMessageView.css:
(.console-user-command.special-user-log > .console-message-body): Added.
(.console-message-body): Added.
(.console-message-body > span): Added.
(.console-message-body > span > :matches(.console-message-enclosed, .console-message-preview, .console-message-preview-divider)): Added.
(.console-message-body > .console-image): Added.
(.console-message-body > .show-grid): Added.
(.console-error-level .console-message-body): Added.
(.console-warning-level .console-message-body): Added.
(.console-log-level.console-image-container::before): Added.
(.console-user-command > .console-message-body): Added.
(.console-warning-level .console-message-body): Added.
(.console-error-level .console-message-body): Added.
(.console-user-command > .console-message-body): Added.
(.console-user-command.special-user-log > .console-message-text): Deleted.
(.console-message-text): Deleted.
(.console-message-text > span): Deleted.
(.console-message-text > span > :matches(.console-message-enclosed, .console-message-preview, .console-message-preview-divider)): Deleted.
(.console-error-level .console-message-text): Deleted.
(.console-warning-level .console-message-text): Deleted.
(.console-user-command > .console-message-text): Deleted.
(.console-warning-level .console-message-text): Deleted.
(.console-error-level .console-message-text): Deleted.
(.console-user-command > .console-message-text): Deleted.
* UserInterface/Views/LogContentView.css:
(.search-in-progress .console-item:not(.filtered-out-by-search).special-user-log .console-message-text .highlighted): Added.
(.search-in-progress .console-item:not(.filtered-out-by-search).special-user-log .console-message-body .highlighted): Deleted.
Renamed variables/classes to be more semantically correct when the content is an image.
- `_messageTextElement` to `_messageBodyElement` (JS)
- `.console-message-text` to `.console-message-body` (CSS)
* UserInterface/Controllers/JavaScriptLogViewController.js:
(WI.JavaScriptLogViewController.prototype.renderPendingMessages):
* UserInterface/Views/Main.css:
(:matches(img, canvas).show-grid):
(@media (prefers-color-scheme: dark) :matches(img, canvas).show-grid):
* UserInterface/Base/FileUtilities.js:
(WI.FileUtilities.screenshotString): Added.
* UserInterface/Models/NativeFunctionParameters.js:
* UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js:
* UserInterface/Images/ConsoleImage.svg: Copied from UserInterface/Images/Canvas.svg.
* Localizations/en.lproj/localizedStrings.js:
LayoutTests:
* js/console.html:
* js/console-expected.txt:
* inspector/console/console-screenshot.html: Added.
* inspector/console/console-screenshot-expected.txt: Added.
* http/tests/inspector/dom/cross-domain-inspected-node-access-expected.txt:
Canonical link: https://commits.webkit.org/210079@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242992 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-15 08:12:21 +00:00
|
|
|
for (let argument of fuzzingArguments)
|
2017-12-04 21:40:55 +00:00
|
|
|
shouldNotThrow(`console.recordEnd(${argument})`);
|
|
|
|
|
|
|
|
debug("");
|
|
|
|
debug("ensure multiple calls don't throw");
|
|
|
|
shouldNotThrow(`console.recordEnd(window.canvas)`);
|
|
|
|
shouldNotThrow(`console.recordEnd(window.canvas)`);
|
|
|
|
shouldNotThrow(`console.recordEnd(window.canvas)`);
|
|
|
|
shouldNotThrow(`console.record(window.canvas)`);
|
|
|
|
shouldNotThrow(`console.record(window.canvas)`);
|
|
|
|
shouldNotThrow(`console.record(window.canvas)`);
|
|
|
|
|
Web Inspector: provide a way to capture a screenshot of a node from within the page
https://bugs.webkit.org/show_bug.cgi?id=194279
<rdar://problem/10731573>
Reviewed by Joseph Pecoraro.
Source/JavaScriptCore:
Add `console.screenshot` functionality, which displays a screenshot of a given object (if
able) within Web Inspector's Console tab. From there, it can be viewed and saved.
Currently, `console.screenshot` will
- capture an image of a `Node` (if provided)
- capture an image of the viewport if nothing is provided
* inspector/protocol/Console.json:
Add `Image` enum value to `ConsoleMessage` type.
* runtime/ConsoleTypes.h:
* inspector/ConsoleMessage.h:
* inspector/ConsoleMessage.cpp:
(Inspector::messageTypeValue):
* runtime/ConsoleClient.h:
* runtime/ConsoleObject.cpp:
(JSC::ConsoleObject::finishCreation):
(JSC::consoleProtoFuncScreenshot): Added.
* inspector/JSGlobalObjectConsoleClient.h:
* inspector/JSGlobalObjectConsoleClient.cpp:
(Inspector::JSGlobalObjectConsoleClient::screenshot): Added.
Source/WebCore:
Test: inspector/console/console-screenshot.html
Add `console.screenshot` functionality, which displays a screenshot of a given object (if
able) within Web Inspector's Console tab. From there, it can be viewed and saved.
Currently, `console.screenshot` will
- capture an image of a `Node` (if provided)
- capture an image of the viewport if nothing is provided
* page/PageConsoleClient.h:
* page/PageConsoleClient.cpp:
(WebCore::PageConsoleClient::addMessage):
(WebCore::PageConsoleClient::screenshot): Added.
* workers/WorkerConsoleClient.h:
* workers/WorkerConsoleClient.cpp:
(WebCore::WorkerConsoleClient::screenshot): Added.
* worklets/WorkletConsoleClient.h:
* worklets/WorkletConsoleClient.cpp:
(WebCore::WorkletConsoleClient::screenshot): Added.
* inspector/CommandLineAPIModuleSource.js:
(CommandLineAPIImpl.prototype.screenshot): Added.
* inspector/InspectorInstrumentation.h:
Source/WebInspectorUI:
Add `console.screenshot` functionality, which displays a screenshot of a given object (if
able) within Web Inspector's Console tab. From there, it can be viewed and saved.
Currently, `console.screenshot` will
- capture an image of a `Node` (if provided)
- capture an image of the viewport if nothing is provided
* UserInterface/Models/ConsoleMessage.js:
(WI.ConsoleMessage):
* UserInterface/Views/ConsoleCommandView.js:
(WI.ConsoleCommandView.prototype.render):
* UserInterface/Views/ConsoleMessageView.js:
(WI.ConsoleMessageView.prototype.render):
(WI.ConsoleMessageView.prototype.toClipboardString):
(WI.ConsoleMessageView.prototype._appendMessageTextAndArguments):
(WI.ConsoleMessageView.prototype._appendSavedResultIndex):
(WI.ConsoleMessageView.prototype._appendStackTrace):
(WI.ConsoleMessageView.prototype._makeExpandable):
(WI.ConsoleMessageView.prototype._handleContextMenu): Added.
* UserInterface/Views/ConsoleMessageView.css:
(.console-user-command.special-user-log > .console-message-body): Added.
(.console-message-body): Added.
(.console-message-body > span): Added.
(.console-message-body > span > :matches(.console-message-enclosed, .console-message-preview, .console-message-preview-divider)): Added.
(.console-message-body > .console-image): Added.
(.console-message-body > .show-grid): Added.
(.console-error-level .console-message-body): Added.
(.console-warning-level .console-message-body): Added.
(.console-log-level.console-image-container::before): Added.
(.console-user-command > .console-message-body): Added.
(.console-warning-level .console-message-body): Added.
(.console-error-level .console-message-body): Added.
(.console-user-command > .console-message-body): Added.
(.console-user-command.special-user-log > .console-message-text): Deleted.
(.console-message-text): Deleted.
(.console-message-text > span): Deleted.
(.console-message-text > span > :matches(.console-message-enclosed, .console-message-preview, .console-message-preview-divider)): Deleted.
(.console-error-level .console-message-text): Deleted.
(.console-warning-level .console-message-text): Deleted.
(.console-user-command > .console-message-text): Deleted.
(.console-warning-level .console-message-text): Deleted.
(.console-error-level .console-message-text): Deleted.
(.console-user-command > .console-message-text): Deleted.
* UserInterface/Views/LogContentView.css:
(.search-in-progress .console-item:not(.filtered-out-by-search).special-user-log .console-message-text .highlighted): Added.
(.search-in-progress .console-item:not(.filtered-out-by-search).special-user-log .console-message-body .highlighted): Deleted.
Renamed variables/classes to be more semantically correct when the content is an image.
- `_messageTextElement` to `_messageBodyElement` (JS)
- `.console-message-text` to `.console-message-body` (CSS)
* UserInterface/Controllers/JavaScriptLogViewController.js:
(WI.JavaScriptLogViewController.prototype.renderPendingMessages):
* UserInterface/Views/Main.css:
(:matches(img, canvas).show-grid):
(@media (prefers-color-scheme: dark) :matches(img, canvas).show-grid):
* UserInterface/Base/FileUtilities.js:
(WI.FileUtilities.screenshotString): Added.
* UserInterface/Models/NativeFunctionParameters.js:
* UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js:
* UserInterface/Images/ConsoleImage.svg: Copied from UserInterface/Images/Canvas.svg.
* Localizations/en.lproj/localizedStrings.js:
LayoutTests:
* js/console.html:
* js/console-expected.txt:
* inspector/console/console-screenshot.html: Added.
* inspector/console/console-screenshot-expected.txt: Added.
* http/tests/inspector/dom/cross-domain-inspected-node-access-expected.txt:
Canonical link: https://commits.webkit.org/210079@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242992 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-03-15 08:12:21 +00:00
|
|
|
debug("");
|
|
|
|
debug("fuzzing of target for console.screenshot");
|
|
|
|
shouldNotThrow(`console.screenshot()`);
|
|
|
|
for (let argument of fuzzingArguments)
|
|
|
|
shouldNotThrow(`console.screenshot(${argument})`);
|
|
|
|
|
|
|
|
debug("");
|
|
|
|
|
Make console a namespace object (like Math/JSON), allowing functions to be called unbound
https://bugs.webkit.org/show_bug.cgi?id=157286
<rdar://problem/26052830>
Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-05-02
Reviewed by Timothy Hatcher.
Source/JavaScriptCore:
This changes `console` to be a global namespace object, like `Math` and `JSON`.
It just holds a bunch of functions, that can be used on their own, unbound.
For example, `[1,2,3].forEach(console.log)` and `var log = console.log; log(1)`
used to throw exceptions and now do not.
Previously console was an Object/Prototype pair, so functions were on
ConsolePrototype (console.__proto__.log) and they needed to be called
Console objects as the `this` value. Now, `console` is just a standard
object with a bunch of functions. Since there is no console prototype the
functions can be passed around and called as expected and they will
just do the right thing.
For compatability with other browsers, `console` was made enumerable
on the global object.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
Add new files and remove old files.
* runtime/CommonIdentifiers.h:
Add "console".
* runtime/ConsoleObject.cpp: Renamed from Source/JavaScriptCore/runtime/ConsolePrototype.cpp.
(JSC::ConsoleObject::ConsoleObject):
(JSC::ConsoleObject::finishCreation):
(JSC::valueToStringWithUndefinedOrNullCheck):
(JSC::consoleLogWithLevel):
(JSC::consoleProtoFuncDebug):
(JSC::consoleProtoFuncError):
(JSC::consoleProtoFuncLog):
(JSC::consoleProtoFuncInfo):
(JSC::consoleProtoFuncWarn):
(JSC::consoleProtoFuncClear):
(JSC::consoleProtoFuncDir):
(JSC::consoleProtoFuncDirXML):
(JSC::consoleProtoFuncTable):
(JSC::consoleProtoFuncTrace):
(JSC::consoleProtoFuncAssert):
(JSC::consoleProtoFuncCount):
(JSC::consoleProtoFuncProfile):
(JSC::consoleProtoFuncProfileEnd):
(JSC::consoleProtoFuncTakeHeapSnapshot):
(JSC::consoleProtoFuncTime):
(JSC::consoleProtoFuncTimeEnd):
(JSC::consoleProtoFuncTimeStamp):
(JSC::consoleProtoFuncGroup):
(JSC::consoleProtoFuncGroupCollapsed):
(JSC::consoleProtoFuncGroupEnd):
Console functions no longer need to check if the this object is
a Console object. They will always just work now.
* runtime/MathObject.cpp:
* runtime/MathObject.h:
* runtime/ConsoleObject.h: Renamed from Source/JavaScriptCore/runtime/ConsolePrototype.h.
(JSC::ConsoleObject::create):
(JSC::ConsoleObject::createStructure):
ConsoleObject is a basic object like MathObject.
* runtime/JSConsole.cpp: Removed.
* runtime/JSConsole.h: Removed.
* runtime/JSGlobalObject.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
Remove JSConsole / ConsolePrototype in favor of the single ConsoleObject.
LayoutTests:
* js/console-expected.txt: Added.
* js/console.html: Added.
Canonical link: https://commits.webkit.org/175386@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200350 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-03 00:51:24 +00:00
|
|
|
</script>
|
|
|
|
<script src="../resources/js-test-post.js"></script>
|
2017-12-04 21:40:55 +00:00
|
|
|
<canvas id="canvas"></canvas>
|
Make console a namespace object (like Math/JSON), allowing functions to be called unbound
https://bugs.webkit.org/show_bug.cgi?id=157286
<rdar://problem/26052830>
Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-05-02
Reviewed by Timothy Hatcher.
Source/JavaScriptCore:
This changes `console` to be a global namespace object, like `Math` and `JSON`.
It just holds a bunch of functions, that can be used on their own, unbound.
For example, `[1,2,3].forEach(console.log)` and `var log = console.log; log(1)`
used to throw exceptions and now do not.
Previously console was an Object/Prototype pair, so functions were on
ConsolePrototype (console.__proto__.log) and they needed to be called
Console objects as the `this` value. Now, `console` is just a standard
object with a bunch of functions. Since there is no console prototype the
functions can be passed around and called as expected and they will
just do the right thing.
For compatability with other browsers, `console` was made enumerable
on the global object.
* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
Add new files and remove old files.
* runtime/CommonIdentifiers.h:
Add "console".
* runtime/ConsoleObject.cpp: Renamed from Source/JavaScriptCore/runtime/ConsolePrototype.cpp.
(JSC::ConsoleObject::ConsoleObject):
(JSC::ConsoleObject::finishCreation):
(JSC::valueToStringWithUndefinedOrNullCheck):
(JSC::consoleLogWithLevel):
(JSC::consoleProtoFuncDebug):
(JSC::consoleProtoFuncError):
(JSC::consoleProtoFuncLog):
(JSC::consoleProtoFuncInfo):
(JSC::consoleProtoFuncWarn):
(JSC::consoleProtoFuncClear):
(JSC::consoleProtoFuncDir):
(JSC::consoleProtoFuncDirXML):
(JSC::consoleProtoFuncTable):
(JSC::consoleProtoFuncTrace):
(JSC::consoleProtoFuncAssert):
(JSC::consoleProtoFuncCount):
(JSC::consoleProtoFuncProfile):
(JSC::consoleProtoFuncProfileEnd):
(JSC::consoleProtoFuncTakeHeapSnapshot):
(JSC::consoleProtoFuncTime):
(JSC::consoleProtoFuncTimeEnd):
(JSC::consoleProtoFuncTimeStamp):
(JSC::consoleProtoFuncGroup):
(JSC::consoleProtoFuncGroupCollapsed):
(JSC::consoleProtoFuncGroupEnd):
Console functions no longer need to check if the this object is
a Console object. They will always just work now.
* runtime/MathObject.cpp:
* runtime/MathObject.h:
* runtime/ConsoleObject.h: Renamed from Source/JavaScriptCore/runtime/ConsolePrototype.h.
(JSC::ConsoleObject::create):
(JSC::ConsoleObject::createStructure):
ConsoleObject is a basic object like MathObject.
* runtime/JSConsole.cpp: Removed.
* runtime/JSConsole.h: Removed.
* runtime/JSGlobalObject.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
Remove JSConsole / ConsolePrototype in favor of the single ConsoleObject.
LayoutTests:
* js/console-expected.txt: Added.
* js/console.html: Added.
Canonical link: https://commits.webkit.org/175386@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200350 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-03 00:51:24 +00:00
|
|
|
</body>
|
|
|
|
</html>
|