2020-06-25 18:01:18 -07:00
|
|
|
/**
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import * as util from 'util';
|
|
|
|
import { JSHandle } from './jsHandle';
|
2020-08-21 18:46:11 -07:00
|
|
|
import { ConsoleMessageChannel, ConsoleMessageInitializer } from '../../protocol/channels';
|
2020-06-25 18:01:18 -07:00
|
|
|
import { ChannelOwner } from './channelOwner';
|
|
|
|
|
2020-08-17 14:36:51 -07:00
|
|
|
type ConsoleMessageLocation = ConsoleMessageInitializer['location'];
|
2020-07-29 17:26:59 -07:00
|
|
|
|
2020-06-26 12:28:27 -07:00
|
|
|
export class ConsoleMessage extends ChannelOwner<ConsoleMessageChannel, ConsoleMessageInitializer> {
|
2020-07-01 18:36:09 -07:00
|
|
|
static from(message: ConsoleMessageChannel): ConsoleMessage {
|
|
|
|
return (message as any)._object;
|
2020-06-25 18:01:18 -07:00
|
|
|
}
|
|
|
|
|
2020-07-10 18:00:10 -07:00
|
|
|
constructor(parent: ChannelOwner, type: string, guid: string, initializer: ConsoleMessageInitializer) {
|
|
|
|
super(parent, type, guid, initializer);
|
2020-06-25 18:01:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
type(): string {
|
2020-06-26 12:28:27 -07:00
|
|
|
return this._initializer.type;
|
2020-06-25 18:01:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
text(): string {
|
2020-06-26 12:28:27 -07:00
|
|
|
return this._initializer.text;
|
2020-06-25 18:01:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
args(): JSHandle[] {
|
2020-06-26 12:28:27 -07:00
|
|
|
return this._initializer.args.map(JSHandle.from);
|
2020-06-25 18:01:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
location(): ConsoleMessageLocation {
|
2020-06-26 12:28:27 -07:00
|
|
|
return this._initializer.location;
|
2020-06-25 18:01:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
[util.inspect.custom]() {
|
|
|
|
return this.text();
|
|
|
|
}
|
|
|
|
}
|