Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/javascript/selenium-webdriver/bidi/evaluateResult.js
2884 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License. You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied. See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
/**
19
* Represents the type of script evaluation result.
20
* Described in https://w3c.github.io/webdriver-bidi/#type-script-EvaluateResult.
21
* @enum {string}
22
*/
23
const EvaluateResultType = {
24
SUCCESS: 'success',
25
EXCEPTION: 'exception',
26
}
27
28
/**
29
* Represents a successful evaluation result.
30
* @class
31
*/
32
class EvaluateResultSuccess {
33
constructor(realmId, value) {
34
this.resultType = EvaluateResultType.SUCCESS
35
this.realmId = realmId
36
this.result = value
37
}
38
}
39
40
/**
41
* Represents an exception that occurred during evaluation of a result.
42
* @class
43
*/
44
class EvaluateResultException {
45
constructor(realmId, exceptionDetails) {
46
this.resultType = EvaluateResultType.EXCEPTION
47
this.realmId = realmId
48
this.exceptionDetails = exceptionDetails
49
}
50
}
51
52
/**
53
* Represents details of an exception.
54
* @class
55
*/
56
class ExceptionDetails {
57
constructor(exceptionDetails) {
58
this.columnNumber = 'columnNumber' in exceptionDetails ? exceptionDetails['columnNumber'] : null
59
this.exception = 'exception' in exceptionDetails ? exceptionDetails['exception'] : null
60
this.lineNumber = 'lineNumber' in exceptionDetails ? exceptionDetails['lineNumber'] : null
61
this.stackTrace = 'stackTrace' in exceptionDetails ? exceptionDetails['stackTrace'] : null
62
this.text = 'text' in exceptionDetails ? exceptionDetails['text'] : null
63
}
64
}
65
66
module.exports = {
67
EvaluateResultType,
68
EvaluateResultSuccess,
69
EvaluateResultException,
70
ExceptionDetails,
71
}
72
73