• No results found

4.2 Graph Construction Process

5.1.1 Terminology

An event e is defined as a tuple e =o, t, where o is the ID of the object

on which the event occurs (an HTML node, the global window, or the global document object), and where t is an event type. At run-time, when an event occurs, it is parametrized with properties of three differ- ent types [5]: i) event properties, a map from strings (property names) to numbers, booleans, strings and DOM nodes (e.g. the which property of the mouse click event identifies the clicked mouse button), ii) form prop- erties, which provide string values for the HTML form fields (e.g. e-mail formatted string for an HTML input element), and iii) the execution environment properties, which represent values for the browser’s state (e.g. window size) that can be influenced by the user. A parametrized

event ep consists of an event e and parameters p associated with that

event. The goal of the process is to compute a set S ={s0, s1, ..., sn} of

scenarios that achieves high code coverage. A scenario si is defined as

a sequence of parametrized events si =ep0, ep1, ..., epm. Each scenario

exercises a certain subset of the application behavior.

During scenario execution, application execution can be influenced by the internal state of the browser. In order to represent this, we

use one special event [5]: e0d = window, “main” that denotes the

loading of the target web page. This event has properties that define the internal state of the brower, e.g. the initial window size, type of the browser, cookie string. By modifying these properties, we can simulate different browser configurations that can influence the control-flow of the application.

We can also establish a relationship between an application feature and a scenario: a scenario causes the manifestation of a particular feature

if its last parametrized event ep

m, in some way, affects the parts of the

page structure where the feature manifests. A parametrized event affects a part of the page structure if: i) it is called on an HTML node that is a part of the structure; ii) it modifies the structure; iii) in the case of server-side communication events, if there is a data dependency from the

message-sending request to the structure. If ep

m affects the structure,

this means that all previous parametrized events ep

j; j < m are also

important from the perspective of the structure, because event chains are created only out of interdependent events (described in the following sections).

48 Chapter 5. Automatic Scenario Generation

ing the execution. New scenarios are generated by: i) extending event chains – all event registrations and data-dependencies during scenario execution are tracked, and new scenarios are generated by extending the event chain of the current scenario with newly registered events, or with previously executed events whose execution potentially depends on the variables and objects modified by the current scenario; and by i) modi- fying the input parameters, i.e. the internal state of the browser (e.g. the initial window size, the type of the browser) and the event parameters – the process tracks how the input parameters influence the control-flow of the application, and generates new scenarios by modifying those in- puts. New scenarios are created and analyzed until a certain coverage is achieved, a given time-budget expended, or a target number of scenarios reached.

Figure 5.1: The process of generating feature scenarios

In the second phase – Scenario Filtering – execution traces of all executed scenarios are analyzed, and the set of scenarios is filtered. If the process targets certain application features, all scenarios that do not cause the manifestation of those features are removed. In addition, we also remove scenarios whose removal does not lower the overall coverage.

5.1 Overview 49

5.1.1

Terminology

An event e is defined as a tuple e =o, t, where o is the ID of the object

on which the event occurs (an HTML node, the global window, or the global document object), and where t is an event type. At run-time, when an event occurs, it is parametrized with properties of three differ- ent types [5]: i) event properties, a map from strings (property names) to numbers, booleans, strings and DOM nodes (e.g. the which property of the mouse click event identifies the clicked mouse button), ii) form prop- erties, which provide string values for the HTML form fields (e.g. e-mail formatted string for an HTML input element), and iii) the execution environment properties, which represent values for the browser’s state (e.g. window size) that can be influenced by the user. A parametrized

event ep consists of an event e and parameters p associated with that

event. The goal of the process is to compute a set S ={s0, s1, ..., sn} of

scenarios that achieves high code coverage. A scenario si is defined as

a sequence of parametrized events si=ep0, ep1, ..., epm. Each scenario

exercises a certain subset of the application behavior.

During scenario execution, application execution can be influenced by the internal state of the browser. In order to represent this, we

use one special event [5]: e0d = window, “main” that denotes the

loading of the target web page. This event has properties that define the internal state of the brower, e.g. the initial window size, type of the browser, cookie string. By modifying these properties, we can simulate different browser configurations that can influence the control-flow of the application.

We can also establish a relationship between an application feature and a scenario: a scenario causes the manifestation of a particular feature

if its last parametrized event ep

m, in some way, affects the parts of the

page structure where the feature manifests. A parametrized event affects a part of the page structure if: i) it is called on an HTML node that is a part of the structure; ii) it modifies the structure; iii) in the case of server-side communication events, if there is a data dependency from the

message-sending request to the structure. If ep

m affects the structure,

this means that all previous parametrized events ep

j; j < m are also

important from the perspective of the structure, because event chains are created only out of interdependent events (described in the following sections).

50 Chapter 5. Automatic Scenario Generation