Skip to content

Commit 9938af7

Browse files
authored
Merge pull request #47 from concordialang/develop
Develop
2 parents 4d78cf3 + 5f2d521 commit 9938af7

File tree

6 files changed

+26
-20
lines changed

6 files changed

+26
-20
lines changed

src/background-script/extension/ExtensionFacade.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export class ExtensionFacade {
8989
) {
9090
if (responseCallback) responseCallback(new Message([], sender.getId()));
9191
}
92-
console.log(message);
9392
if (message.includesAction(Command.Start)){
9493
if (!_this.extensionIsEnabled) {
9594
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {

src/content-script/crawler/Interactor.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import { HTMLElementType } from '../enums/HTMLElementType';
22
import { HTMLEventType } from '../enums/HTMLEventType';
33
import { HTMLInputType } from '../enums/HTMLInputType';
44
import { ElementInteraction } from './ElementInteraction';
5-
import { sleep } from '../util';
65
import { InteractionResult } from './InteractionResult';
7-
import { ForcingExecutionStoppageErrorFromInteraction } from './ForcingExecutionStoppageErrorFromInteraction';
86

97
export class Interactor {
108
constructor(private window: Window) {}

src/content-script/spec-analyser/FeatureUtil.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ export class FeatureUtil {
2525
feature.setName(featureName);
2626
feature.url = url;
2727

28-
const scenario = this.createScenario(featureName);
28+
const scenario = this.createScenario();
2929
feature.addScenario(scenario);
3030

3131
return feature;
3232
}
3333

34-
createScenario(featureName: string): Scenario {
35-
const scenario = new Scenario(featureName + ' - ' + this.dictionary.scenarioDefaultName);
34+
createScenario(): Scenario {
35+
const scenario = new Scenario(this.dictionary.scenarioDefaultName);
3636

3737
return scenario;
3838
}

src/content-script/spec-analyser/UIElementGenerator.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ export class UIElementGenerator {
7676
}
7777

7878
// editabled
79-
uiElm.setProperty(new UIProperty(PropertyTypes.EDITABLE, true));
79+
if(elm.disabled || elm.readOnly){
80+
uiElm.setProperty(new UIProperty(PropertyTypes.EDITABLE, false));
81+
}
8082
}
8183

8284
// required
@@ -300,12 +302,8 @@ export class UIElementGenerator {
300302
return uiElmType;
301303
}
302304

303-
private gerateDataType(elm: HTMLElement): string {
304-
let uiElmDataType = '';
305-
306-
if (elm.nodeName == ValidUiElementsNodes.TEXTAREA) {
307-
uiElmDataType = DataTypes.STRING;
308-
}
305+
private gerateDataType(elm: HTMLElement): string | null{
306+
let uiElmDataType: string | null = null;
309307

310308
if (elm.nodeName == ValidUiElementsNodes.INPUT) {
311309
let inputType = (elm as HTMLInputElement).type;
@@ -316,8 +314,6 @@ export class UIElementGenerator {
316314
uiElmDataType = DataTypes.TIME;
317315
} else if (inputType == HTMLInputType.DateTimeLocal) {
318316
uiElmDataType = DataTypes.DATETIME;
319-
} else {
320-
uiElmDataType = DataTypes.STRING;
321317
}
322318
}
323319

src/content-script/spec-analyser/VariantSentencesGenerator.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { VariantSentenceType } from '../enums/VariantSentenceType';
55
import { getValidUiElementsNodes, isIterable, isVisible } from '../util';
66
import { UIElementGenerator } from './UIElementGenerator';
77
import { UiElementsTypes } from '../enums/UiElementsTypes';
8+
import { HTMLElementType } from '../enums/HTMLElementType';
89

910
export class VariantSentencesGenerator {
1011
constructor(private uiElementGenerator: UIElementGenerator) {}
@@ -117,6 +118,7 @@ export class VariantSentencesGenerator {
117118
VariantSentenceType.AND,
118119
VariantSentenceActions.NOTSEE,
119120
[{ property: property, value: value }],
121+
false
120122
);
121123
} else {
122124
sentences = this.createSentencesForMutations(
@@ -262,7 +264,8 @@ export class VariantSentencesGenerator {
262264
node,
263265
VariantSentenceType.AND,
264266
action,
265-
[{ property: 'hidden', value: node.hidden }]
267+
[{ property: 'hidden', value: node.hidden }],
268+
false
266269
);
267270
}
268271

@@ -274,10 +277,22 @@ export class VariantSentencesGenerator {
274277
type: VariantSentenceType,
275278
action: string,
276279
attr: Array<{ property: string; value: string }> = [],
280+
checkVisibility = true
277281
): VariantSentence[] {
278282
let sentences: VariantSentence[] = [];
279283

280-
let uiElement: UIElement | null = this.uiElementGenerator.createFromElement(element);
284+
let uiElement: UIElement | null = null;
285+
286+
if(checkVisibility){
287+
uiElement =
288+
!(element instanceof Text) && isVisible(element)
289+
? this.uiElementGenerator.createFromElement(element)
290+
: null
291+
}
292+
else {
293+
uiElement = this.uiElementGenerator.createFromElement(element);
294+
}
295+
281296
if (uiElement) {
282297
sentences.push(new VariantSentence(type, action, uiElement, attr));
283298
} else {

src/content-script/util.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export function isIterable(obj): boolean {
202202
}
203203

204204
export function isVisible(elm: HTMLElement) {
205-
if (elm.hidden || elm.style.display === 'none' || elm.style.visibility === 'hidden') {
205+
if (!elm || elm.hidden || elm.style.display === 'none' || elm.style.visibility === 'hidden') {
206206
return false;
207207
}
208208

@@ -249,11 +249,9 @@ export function getURLasString(url: URL, config: Config): string {
249249
function isURLToBeConsideredFull(url: URL, config: Config): boolean {
250250
for(let fullUrl of config.considerFullUrl){
251251
if(url.href.includes(fullUrl.href)){
252-
console.log("url:", url.href, true);
253252
return true;
254253
}
255254
}
256-
console.log("url:", url.href, false);
257255
return false;
258256
}
259257

0 commit comments

Comments
 (0)