├── selblocks.PNG
├── sel-blocks-fx_xpi
├── chrome
│ ├── content
│ │ ├── selblocks.css
│ │ ├── extensions
│ │ │ ├── browser.xul
│ │ │ ├── extension_sequencer_missing.xul
│ │ │ ├── selenium-executionloop-handleAsExitTest.js
│ │ │ ├── name-space.js
│ │ │ ├── logger.js
│ │ │ ├── expression-parser.js
│ │ │ ├── selenium-executionloop-handleAsTryBlock.js
│ │ │ ├── function-intercepting.js
│ │ │ └── browser.js
│ │ ├── SeLiteExtensionSequencerManifest.js
│ │ └── about.xul
│ └── skin
│ │ ├── icon.png
│ │ ├── leftbracket.png
│ │ ├── rightbracket.png
│ │ ├── favicon-32x32.png
│ │ ├── favicon-64x64.png
│ │ └── selblocksLogo.png
├── chrome.manifest
├── install.rdf
└── smoketest.side
├── sel-blocksTests
├── data
│ ├── forxml.xml
│ └── forjson.json
├── negativeTests
│ ├── _SelBlocks-regression-negative.html
│ ├── README.html
│ ├── _results.log
│ └── try01 - try without matching catch.html
├── eval.html
├── _SelBlocks-testpage.html
├── README.html
├── exitTest01.html
├── function04-issue2.html
├── exitTest02 - from within a loop.html
├── exitTest03 - from within a function.html
├── label-issue2.html
├── continue-break02.html
├── continue-break03.html
├── loadxmlvars.html
├── continue-break04.html
├── for.html
├── loadjsonvars.html
├── branching02.html
├── foreach.html
├── function02.html
├── try01 - no-op try.html
├── branching01.html
├── function05-scoping-issue5.html
├── forxml.html
├── forjson.html
├── continue-break01.html
├── try02 - try-finally, w-no error.html
├── foreach-xpath.html
├── while.html
├── try03 - try-catch, but no error.html
├── if03.html
├── try04 - catch specific error.html
├── try21 - catch failed verify command.html
├── try22 - exitTest w-finally processing.html
├── function01.html
├── try15 - command bubbling, intra-try break.html
├── try17 - command bubbling, intra-try continue.html
├── try14 - command bubbling, break wfinally.html
├── try16 - command bubbling, continue w-finally.html
├── try18 - command bubbling, error replaced by return.html
├── try19 - command bubbling, error replaced by throw.html
├── nested-loops.html
├── try07 - bubble up to catch ALL.html
├── try10 - bubble up to catch specific error.html
├── try09 - bubble out of no-op try to catch specific error.html
├── try05 - catch specific error, then finally.html
├── try08 - bubble up to catch ALL via finally.html
├── if01.html
├── try11 - bubble up to catch specific error via finally.html
├── try12 - throw, catch, rethrow.html
├── try06 - catch-throw, finally-throw.html
├── try20 - command bubbling, return replaced by error.html
├── if02.html
├── function03-recursive.html
├── try13 - bubble out of nested function calls.html
└── _SelBlocks-regression.html
├── selenese-scripts
├── various
│ ├── varset.json
│ ├── varset.xml
│ ├── misc_case.html
│ ├── plain_function_definition_case.html
│ ├── verifyParameter_case.html
│ ├── plain_function_call_case.html
│ ├── sel-blocks-global_suite.html
│ ├── use_data_from_files_case.html
│ ├── iterate_case.html
│ ├── whilePromise_case.html
│ ├── try_catch_function_calls_case.html
│ ├── assertFunctionFailure_def_case.html
│ ├── repeat_until_case.html
│ ├── promised_case.html
│ └── ifPromise_case.html
└── call-back
│ ├── call_back_suite.html
│ ├── selenese_functions_case.html
│ └── call_back_case.html
├── .eslintrc.json
├── README.md
├── notes
├── SeleniumServer-notes.txt
├── selenium-plugins-page.txt
├── design-notes.txt
└── Mozilla-page.txt
├── selenese-scripts-negative
├── assertFunctionFailure_case.html
├── sel-blocks-global_negative_suite.html
├── try_with_no_catch_nor_finally_at_top_level_case.html
├── try_with_unmatching_catch_at_top_level_case.html
├── try_without_catch_at_top_level_case.html
└── successful_try_then_failed_assert.html
├── setup_proxy.bat
└── setup_proxy.sh
/selblocks.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeLite/SelBlocksGlobalOld/HEAD/selblocks.PNG
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/content/selblocks.css:
--------------------------------------------------------------------------------
1 | .code {
2 | font-family: courier;
3 | }
4 |
--------------------------------------------------------------------------------
/sel-blocksTests/data/forxml.xml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeLite/SelBlocksGlobalOld/HEAD/sel-blocksTests/data/forxml.xml
--------------------------------------------------------------------------------
/sel-blocksTests/data/forjson.json:
--------------------------------------------------------------------------------
1 | [
2 | { jname: "dilbert" }
3 | ,{ jname: "dogbert" }
4 | ,{ jname: "wally" }
5 | ]
6 |
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/skin/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeLite/SelBlocksGlobalOld/HEAD/sel-blocks-fx_xpi/chrome/skin/icon.png
--------------------------------------------------------------------------------
/selenese-scripts/various/varset.json:
--------------------------------------------------------------------------------
1 | [
2 | { "userid": "dilbert", "role": "superuser" },
3 | { userid: "wally", "role": "lazyuser" }
4 | ]
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/skin/leftbracket.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeLite/SelBlocksGlobalOld/HEAD/sel-blocks-fx_xpi/chrome/skin/leftbracket.png
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/skin/rightbracket.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeLite/SelBlocksGlobalOld/HEAD/sel-blocks-fx_xpi/chrome/skin/rightbracket.png
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/skin/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeLite/SelBlocksGlobalOld/HEAD/sel-blocks-fx_xpi/chrome/skin/favicon-32x32.png
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/skin/favicon-64x64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeLite/SelBlocksGlobalOld/HEAD/sel-blocks-fx_xpi/chrome/skin/favicon-64x64.png
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/skin/selblocksLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeLite/SelBlocksGlobalOld/HEAD/sel-blocks-fx_xpi/chrome/skin/selblocksLogo.png
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "parserOptions": {
3 | "ecmaVersion": 6,
4 | "ecmaFeatures": {
5 | }
6 | },
7 | "rules": {
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/selenese-scripts/various/varset.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome.manifest:
--------------------------------------------------------------------------------
1 | content selite-selblocks-global chrome/content/
2 | skin selite-selblocks-global classic chrome/skin/
3 |
4 | # custom extension(s)
5 | overlay chrome://browser/content/browser.xul chrome://selite-selblocks-global/content/extensions/browser.xul
6 |
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/content/extensions/browser.xul:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | SelBlocks Global
2 | =========
3 |
4 | [SelBlocks Global](https://selite.github.io/SelBlocksGlobal) is an enhancement of [SelBlocks](https://github.com/refactoror/SelBlocks/). It's a part of [SeLite](https://selite.github.io/). However, SelBlocks Global's code is in a repository separate from [the rest of SeLite](https://github.com/SeLite/SeLite).
5 |
6 | See extensive [documentation of SeLite](http://selite.github.io/) for benefits and installation.
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/content/extensions/extension_sequencer_missing.xul:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SeLite requires SeLite Extension Sequencer, which is missing (or is disabled). Please, install (or enable) it and re-start Firefox. See http://selite.github.io/Components .
6 |
7 |
8 |
--------------------------------------------------------------------------------
/selenese-scripts/call-back/call_back_suite.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Test Suite
7 |
8 |
9 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/sel-blocksTests/negativeTests/_SelBlocks-regression-negative.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Test Suite
7 |
8 |
9 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/sel-blocksTests/eval.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | eval
8 |
9 |
10 |
11 |
12 | eval
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/sel-blocksTests/_SelBlocks-testpage.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Test Page
4 |
5 |
6 |
7 |
8 |
9 | SelBlocks Test Page
10 |
11 |
12 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/sel-blocksTests/README.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | README
8 |
9 |
10 |
11 |
12 | README
13 |
14 |
15 |
16 | clearLog
17 |
18 |
19 |
20 |
21 | open
22 | http://refactoror.net/_SelBlocks-testpage.html
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/sel-blocksTests/exitTest01.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | exitTest01
8 |
9 |
10 |
11 |
12 | exitTest01
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | exitTest
21 |
22 |
23 |
24 |
25 | throw
26 | "shouldn't happen"
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/content/extensions/selenium-executionloop-handleAsExitTest.js:
--------------------------------------------------------------------------------
1 | // selbocks name-space
2 | "use strict";
3 |
4 | // Following assignments is purely for JSDoc.
5 | /** @namespace */
6 | selblocks= selblocks;
7 |
8 | /** This function replaces native Selenium command-handling for the exitScript command.
9 | * (See TestLoop.prototype.resume() in chrome/content/selenium-core/scripts/selenium-executionloop.js.)
10 | * This causes the script to simply halt rather continuing on to the next command.
11 | */
12 | selblocks.handleAsExitTest = function() {
13 | try {
14 | selenium.browserbot.runScheduledPollers();
15 | this.testComplete();
16 | }
17 | catch (e) {
18 | // seems highly unlikely that there would be an error in this very simple case
19 | this._handleCommandError(e); // marks command as failed (red), and overall test as failed
20 | this.testComplete();
21 | }
22 | selblocks.LOG.info("TEST HALTED");
23 | };
24 |
--------------------------------------------------------------------------------
/notes/SeleniumServer-notes.txt:
--------------------------------------------------------------------------------
1 | Like the Selenium IDE addon itself,
2 | `sel-blocks-fx.xpi` is a zip archive containing various .js files.
3 | The SelBlocks `user-extensions.js` file
4 | is a combination of .js files drawn from the .xpi file.
5 | See: https://github.com/refactoror/SelBlocks/tree/master/sel-blocks-fx_xpi/chrome/content/extensions
6 | Specifically, it is the concatenation of those files in the order specified by `extension-loader.xul`,
7 | plus the `build/user-extensions-base.js` file,
8 | (inserted just before `selblocks.js`).
9 |
10 | When Selenium Server loads `user-extensions.js`, `$$.seleniumEnv` is set to `"server"`,
11 | and a `testCase` object is created that simulates the object by the same name in Selenium IDE.
12 | SelBlocks then operates as it does in Selenium IDE.
13 |
14 | One major exception is local file access, which is not supported by Selenium Server.
15 | This might be a problem for commands like `loadJsonVars`, `loadXmlVars`, `forJson` and `forXml`.
16 | However, files can also be accessed via http.
17 |
--------------------------------------------------------------------------------
/sel-blocksTests/function04-issue2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | function04-issue2
8 |
9 |
10 |
11 |
12 | function04-issue2
13 |
14 |
15 | function
16 | xyz
17 |
18 |
19 |
20 | log
21 | 'here'
22 |
23 |
24 |
25 | endFunction
26 |
27 |
28 |
29 |
30 | call
31 | xyz
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/selenese-scripts-negative/assertFunctionFailure_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | assertFunctionFailure_case
8 |
9 |
10 |
11 |
12 | assertFunctionFailure_case
13 |
14 |
15 |
16 | function
17 | empty
18 |
19 |
20 |
21 | endFunction
22 |
23 |
24 |
25 |
26 |
27 | call
28 | assertFunctionFailure
29 | func='empty'
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/notes/selenium-plugins-page.txt:
--------------------------------------------------------------------------------
1 | http://docs.seleniumhq.org/download/#side_plugins
2 |
3 |
4 |
SelBlocks
5 |
12 |
13 |
14 | Released: February 8, 2013
15 | Version: 2.0
16 |
17 |
18 |
This plugin is a language extension for Selenium IDE that provides javascript-like conditionals, looping, callable functions, error catching, and JSON/XML driven parameterization.
19 |
20 |
--------------------------------------------------------------------------------
/sel-blocksTests/negativeTests/README.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | README
8 |
9 |
10 |
11 |
12 | README
13 |
14 |
15 |
16 | clearLog
17 |
18 |
19 |
20 |
21 |
22 |
23 | open
24 | http://refactoror.net/_SelBlocks-testpage.html
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/selenese-scripts/various/misc_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | misc_case
8 |
9 |
10 |
11 |
12 | misc_case
13 |
14 |
15 | store
16 | Hello
17 | hello
18 |
19 |
20 | assertEval
21 | $hello==="Hello"
22 | true
23 |
24 |
25 |
26 | assertEval
27 | '<' + '>'
28 | <>'<' + '>'<>
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/sel-blocksTests/exitTest02 - from within a loop.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | exitTest02
8 |
9 |
10 |
11 |
12 | exitTest02
13 |
14 |
15 |
16 | for
17 | i=0; i < 5; i++
18 |
19 |
20 |
21 | if
22 | i == 3
23 |
24 |
25 |
26 | exitTest
27 |
28 |
29 |
30 |
31 | endIf
32 |
33 |
34 |
35 |
36 | endFor
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/install.rdf:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | selblocks-global@selite.googlecode.com
6 | SeLite SelBlocks Global
7 | 2.71
8 | Chris Noe, Peter Kehl
9 | For structured automated test scripts in Selenium-IDE
10 | 2
11 | http://selite.github.io/SelBlocksGlobal
12 |
13 |
14 | {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
15 | 44.0
16 | 56.*
17 |
18 |
19 | chrome://selite-selblocks-global/skin/favicon-32x32.png
20 | chrome://selite-selblocks-global/skin/favicon-64x64.png
21 |
22 |
23 |
--------------------------------------------------------------------------------
/selenese-scripts/various/plain_function_definition_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | plain_function_definition
8 |
9 |
10 |
11 |
12 | plain_function_definition_case
13 |
14 |
15 | function
16 | plain_function
17 |
18 |
19 |
20 |
21 | getEval
22 | this.plain_function_has_run= true
23 |
24 |
25 |
26 | endFunction
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/sel-blocksTests/exitTest03 - from within a function.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | exitTest03
8 |
9 |
10 |
11 |
12 | exitTest03
13 |
14 |
15 |
16 | call
17 | doSubExit
18 |
19 |
20 |
21 | throw
22 | "shouldn't happen"
23 |
24 |
25 |
26 | function
27 | doSubExit
28 |
29 |
30 |
31 | exitTest
32 |
33 |
34 |
35 |
36 | endFunction
37 | doSubExit
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/selenese-scripts/various/verifyParameter_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | verifyParameter_case
8 |
9 |
10 |
11 |
12 | verifyParameter_case
13 |
14 |
15 | function
16 | verifyParameter
17 | $yes
18 |
19 |
20 | assertEval
21 | $yes
22 | yes
23 |
24 |
25 | endFunction
26 |
27 |
28 |
29 |
30 |
31 | call
32 | verifyParameter
33 | yes= 'yes'
34 |
35 |
36 | call
37 | verifyParameter
38 | =<>({ yes: 'yes' })<>
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/selenese-scripts-negative/sel-blocks-global_negative_suite.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Test Suite
7 |
8 |
9 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/selenese-scripts-negative/try_with_no_catch_nor_finally_at_top_level_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | try_catch_finally_case
8 |
9 |
10 |
11 |
12 | try_catch_finally_case
13 |
14 |
15 |
16 |
17 | try
18 |
19 |
20 |
21 |
22 | throw
23 | 'throw_test'
24 |
25 |
26 |
27 |
28 | endTry
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/selenese-scripts/various/plain_function_call_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | plain_function_call
8 |
9 |
10 |
11 |
12 | plain_function_call_case
13 |
14 |
15 | getEval
16 | this.plain_function_has_run= undefined
17 |
18 |
19 |
20 | call
21 | plain_function
22 |
23 |
24 |
25 | getEval
26 | if( !this.plain_function_has_run ) throw "plain_function didn't run, or it didn't set global variable plain_function_has_run"
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/sel-blocksTests/label-issue2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | label-issue2
8 |
9 |
10 |
11 |
12 | label-issue2
13 |
14 |
15 | label
16 | top
17 |
18 |
19 |
20 | gotoIf
21 | "${status}" == "done"
22 | bottom
23 |
24 |
25 | log
26 | 'here'
27 |
28 |
29 |
30 | storeEval
31 | "done"
32 | status
33 |
34 |
35 | goto
36 | top
37 |
38 |
39 |
40 | label
41 | bottom
42 |
43 |
44 |
45 | deleteVars
46 | status
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/sel-blocksTests/negativeTests/_results.log:
--------------------------------------------------------------------------------
1 |
2 |
3 | [info] Executing: |open | http://refactoror.net/_SelBlocks-testpage.html | |
4 | [info] Test case passed
5 | [info] Playing test case try01 - try without matching catch
6 | [info] Executing: |log | "-- try without matching catch --" | |
7 | [info] [selbench] -- try without matching catch --
8 | [info] Executing: |resetEmitted | | |
9 | [info] Executing: |assertEval | selblocks.tcf.nestingLevel | -1 |
10 | [info] script is: selblocks.tcf.nestingLevel
11 | [info] Executing: |try | miss | |
12 | [info] Executing: |assertEval | true | true |
13 | [info] script is: true
14 | [info] Executing: |throw | "blamo will NOT be caught at all" | |
15 | [info] [selblocks] Bubbling suspended while finally block runs
16 | [info] [selblocks] branch => @11: [finally]
17 | [info] Executing: |finally | | |
18 | [info] Executing: |log | "finally" | |
19 | [info] [selbench] finally
20 | [info] Executing: |endTry | miss | |
21 | [error] [selblocks] Error was not caught: 'blamo will NOT be caught at all'
22 | [error] Unexpected Exception: SelblocksError: blamo will NOT be caught at all. name -> SelblocksError, message -> blamo will NOT be caught at all, idx -> 6
23 | [info] Test case failed
24 | [info] Test suite completed: 2 played, 1 failed
25 |
26 |
--------------------------------------------------------------------------------
/selenese-scripts-negative/try_with_unmatching_catch_at_top_level_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | try_catch_finally_case
8 |
9 |
10 |
11 |
12 | try_catch_finally_case
13 |
14 |
15 |
16 |
17 | try
18 |
19 |
20 |
21 |
22 | throw
23 | 'throw_test'
24 |
25 |
26 |
27 | catch
28 | 'do not match the error'
29 |
30 |
31 |
32 | endTry
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/selenese-scripts-negative/try_without_catch_at_top_level_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | try_catch_finally_case
8 |
9 |
10 |
11 |
12 | try_catch_finally_case
13 |
14 |
15 |
16 |
17 | try
18 |
19 |
20 |
21 |
22 | throw
23 | 'throw_test'
24 |
25 |
26 |
27 |
28 | finally
29 |
30 |
31 |
32 |
33 | endTry
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/content/extensions/name-space.js:
--------------------------------------------------------------------------------
1 | /* Copyright 2011 Chris Noe
2 | * Copyright 2015, 2016 Peter Kehl
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 1.1. If a copy of the MPL was not distributed with this file,
5 | * You can obtain one at http://mozilla.org/MPL/1.1/.
6 | */
7 | // SelBlocks name-space
8 | "use strict";
9 |
10 | /** @namespace */
11 | var selblocks = {
12 | name: "selblocks"
13 | ,seleniumEnv: "ide"
14 | ,globalContext: this // alias for global Selenium scope
15 | };
16 |
17 | /** Starting with FF4 lots of objects are in an XPCNativeWrapper,
18 | * and we need the underlying object for == and for..in operations.
19 | * @member {function}
20 | */
21 | selblocks.unwrapObject = function unwrapObject(obj) {
22 | if (typeof(obj) === "undefined" || obj == null)
23 | return obj;
24 | if (obj.wrappedJSObject)
25 | return obj.wrappedJSObject;
26 | return obj;
27 | };
28 |
29 | /** @member {function}
30 | * */
31 | selblocks.fmtCmd = function fmtCmd(cmd) {
32 | var c = cmd.command!==undefined
33 | ? cmd.command.trimLeft() // trimLeft() is for commands indented with whitespace (when using SeLite ClipboardAndIndent)
34 | : cmd.command;
35 | if (cmd.target) { c += "|" + cmd.target; }
36 | if (cmd.value) { c += "|" + cmd.value; }
37 | return c;
38 | };
--------------------------------------------------------------------------------
/sel-blocksTests/continue-break02.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | continue-break02
8 |
9 |
10 |
11 |
12 | continue-break02
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | store
21 | 0
22 | i
23 |
24 |
25 | while
26 | i++ < 10
27 |
28 |
29 |
30 | continue
31 | i==3
32 |
33 |
34 |
35 | break
36 | i==5
37 |
38 |
39 |
40 | emit
41 | "iter=${i}"
42 |
43 |
44 |
45 | endWhile
46 |
47 |
48 |
49 |
50 |
51 | assertEmitted
52 | "iter=1~iter=2~iter=4"
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/sel-blocksTests/continue-break03.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | continue-break03
8 |
9 |
10 |
11 |
12 | continue-break03
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | foreach
21 | fe
22 | "dilbert","dogbert","wally"
23 |
24 |
25 | continue
26 | fe=="dogbert"
27 |
28 |
29 |
30 | break
31 | fe=="wally"
32 |
33 |
34 |
35 | emit
36 | "iter=${fe}"
37 |
38 |
39 |
40 | endForeach
41 |
42 |
43 |
44 |
45 |
46 | assertEmitted
47 | "iter=dilbert"
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/sel-blocksTests/loadxmlvars.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | loadxmlvars
8 |
9 |
10 |
11 |
12 | loadxmlvars
13 |
14 |
15 |
16 | expectError
17 | "Requires an XML file path or URL"
18 |
19 |
20 |
21 | loadXmlVars
22 |
23 |
24 |
25 |
26 |
27 | expectError
28 | "Multiple XML elements are not valid for this command"
29 |
30 |
31 |
32 | loadXmlVars
33 | http://refactoror.net/forxml.xml
34 |
35 |
36 |
37 |
38 | expectError
39 | '"flubber" is not a boolean expression'
40 |
41 |
42 |
43 | loadXmlVars
44 | http://refactoror.net/forxml.xml
45 | "flubber"
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/sel-blocksTests/continue-break04.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | continue-break04
8 |
9 |
10 |
11 |
12 | continue-break04
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | forXml
21 | http://refactoror.net/forxml.xml
22 |
23 |
24 |
25 | continue
26 | xname=="dogbert"
27 |
28 |
29 |
30 | break
31 | xname=="wally"
32 |
33 |
34 |
35 | emit
36 | "iter=${xname}"
37 |
38 |
39 |
40 | endForXml
41 |
42 |
43 |
44 |
45 |
46 | assertEmitted
47 | "iter=dilbert"
48 |
49 |
50 |
51 | resetEmitted
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/sel-blocksTests/for.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | for
8 |
9 |
10 |
11 |
12 | for
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | deleteVars
21 | f
22 |
23 |
24 |
25 | emit
26 | "START ${f}"
27 |
28 |
29 |
30 | for
31 | s=0,f=3; f <= 5; f++
32 |
33 |
34 |
35 | emit
36 | "iter=${f}.${s}"
37 |
38 |
39 |
40 | endFor
41 |
42 |
43 |
44 |
45 | emit
46 | "END ${f}"
47 |
48 |
49 |
50 |
51 | assertEmitted
52 | "START $" + "{f}~iter=3.0~iter=4.0~iter=5.0~END $" + "{f}"
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/sel-blocksTests/loadjsonvars.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | loadjsonvars
8 |
9 |
10 |
11 |
12 | loadjsonvars
13 |
14 |
15 |
16 | expectError
17 | "Requires a JSON file path or URL"
18 |
19 |
20 |
21 | loadJsonVars
22 |
23 |
24 |
25 |
26 |
27 | expectError
28 | "Multiple JSON objects are not valid for this command"
29 |
30 |
31 |
32 | loadJsonVars
33 | http://refactoror.net/forjson.json
34 |
35 |
36 |
37 |
38 | expectError
39 | '"flubber" is not a boolean expression'
40 |
41 |
42 |
43 | loadJsonVars
44 | http://refactoror.net/forjson.json
45 | "flubber"
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/setup_proxy.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | REM Following is for expansion of variables at runtime - e.g. !e! instead of %e%
3 | setlocal EnableDelayedExpansion
4 | SET script_folder=%~dp0
5 | cd %script_folder:~0,-1%
6 |
7 | REM Based on https://developer.mozilla.org/en/Setting_up_extension_development_environment and http://kb.mozillazine.org/Profile_folder_-_Firefox
8 | REM This script accepts an optional parameter, which is a name of Firefox profile. Otherwise it uses 'default' profile. Either way, the profile must have been created by Firefox (i.e. its folder name must be in standard format).
9 | if not "%1"=="" (
10 | set profile=%1
11 | ) else (
12 | set profile=default
13 | )
14 |
15 | FOR /D %%c in ("%APPDATA%\Mozilla\Firefox\Profiles\*.%profile%") DO set p=%%c
16 | if defined p (
17 | set e="%p%\extensions"
18 | REM If you have not got any extensions in Firefox profile yet, there is no 'extensions' folder. So create it.
19 | if not exist "!e!" (
20 | mkdir "!e!"
21 | )
22 |
23 | REM Now set up the actual extensions, unless they are already installed from XPI
24 | REM Do not use: echo %CD%.>target-file. Use: cd >target-file. For some reason %CD% doesn't get updated after I change directory.
25 | if not exist "!e!\selblocks-global@selite.googlecode.com.xpi" (
26 | cd sel-blocks-fx_xpi
27 | cd > "!e!\selblocks-global@selite.googlecode.com"
28 | cd ..
29 | )
30 | ) else (
31 | echo Could not find a Firefox profile "%profile%"
32 | )
33 |
--------------------------------------------------------------------------------
/selenese-scripts/various/sel-blocks-global_suite.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Test Suite
7 |
8 |
9 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/sel-blocksTests/branching02.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | branching02
8 |
9 |
10 |
11 |
12 | branching02
13 |
14 |
15 |
16 |
17 | expectError
18 | "Target label 'NOWHERE' is not found"
19 |
20 |
21 |
22 | goto
23 | NOWHERE
24 |
25 |
26 |
27 |
28 | expectError
29 | "Target label 'NOWHERE' is not found"
30 |
31 |
32 |
33 | gotoIf
34 | true
35 | NOWHERE
36 |
37 |
38 |
39 | expectError
40 | "Requires a number > 1"
41 |
42 |
43 |
44 | skipNext
45 | -1
46 |
47 |
48 |
49 |
50 | expectError
51 | "random is not defined"
52 |
53 |
54 |
55 | skipNext
56 | random
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/sel-blocksTests/foreach.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | foreach
8 |
9 |
10 |
11 |
12 | foreach
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | deleteVars
21 | _i, fe
22 |
23 |
24 |
25 | emit
26 | "START ${_i}-${fe}"
27 |
28 |
29 |
30 | foreach
31 | fe
32 | "dilbert", "dogbert", "wally"
33 |
34 |
35 | emit
36 | "${_i}) ${fe}"
37 |
38 |
39 |
40 | endForeach
41 |
42 |
43 |
44 |
45 | emit
46 | "END ${_i}-${fe}"
47 |
48 |
49 |
50 |
51 | assertEmitted
52 | "START $" + "{_i}-$" + "{fe}~0) dilbert~1) dogbert~2) wally~END $" + "{_i}-$" + "{fe}"
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/sel-blocksTests/function02.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | function02
8 |
9 |
10 |
11 |
12 | function02
13 |
14 |
15 |
16 | expectError
17 | "Function does not exist: NONEXISTENT"
18 |
19 |
20 |
21 | call
22 | NONEXISTENT
23 |
24 |
25 |
26 |
27 | resetEmitted
28 |
29 |
30 |
31 |
32 | script
33 | doDeprecated
34 | sname
35 |
36 |
37 | emit
38 | "sname=${sname},srole=${srole}"
39 |
40 |
41 |
42 | endScript
43 | doDeprecated
44 |
45 |
46 |
47 | call
48 | doDeprecated
49 | sname = "wally", srole = "lazy"
50 |
51 |
52 | assertEmitted
53 | "sname=wally,srole=lazy"
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/selenese-scripts/various/use_data_from_files_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | use_data_from_files_case
8 |
9 |
10 |
11 |
12 | use_data_from_files_case
13 |
14 |
15 | loadXmlVars
16 | file://<> SeLiteSettings.getTestSuiteFolder() <>/varset.xml
17 | storedVars.userid==="dilbert"
18 |
19 |
20 | assertEval
21 | storedVars.role
22 | superuser
23 |
24 |
25 |
26 | loadJsonVars
27 | file://<> SeLiteSettings.getTestSuiteFolder() <>/varset.json
28 | storedVars.userid==="dilbert"
29 |
30 |
31 | assertEval
32 | storedVars.role
33 | superuser
34 |
35 |
36 |
37 | loadJsonVars
38 | file://<> SeLiteSettings.getTestSuiteFolder() <>/varset.json
39 | storedVars.userid==="wally"
40 |
41 |
42 | assertEval
43 | storedVars.role
44 | lazyuser
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/content/SeLiteExtensionSequencerManifest.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | SeLiteExtensionSequencer.registerPlugin( {
3 | name: 'SeLite SelBlocks Global',
4 | id: 'selblocks-global@selite.googlecode.com',
5 | coreURL: [
6 | 'chrome://selite-selblocks-global/content/extensions/name-space.js',
7 | 'chrome://selite-selblocks-global/content/extensions/logger.js',
8 | 'chrome://selite-selblocks-global/content/extensions/function-intercepting.js',
9 | 'chrome://selite-selblocks-global/content/extensions/xpath-processing.js',
10 | 'chrome://selite-selblocks-global/content/extensions/expression-parser.js',
11 | 'chrome://selite-selblocks-global/content/extensions/selenium-executionloop-handleAsExitTest.js',
12 | 'chrome://selite-selblocks-global/content/extensions/selenium-executionloop-handleAsTryBlock.js',
13 | 'chrome://selite-selblocks-global/content/extensions/selblocks.js'
14 | ],
15 | xmlURL: 'chrome://selite-selblocks-global/content/reference.xml',
16 | infoURL: 'https://addons.mozilla.org/en-US/firefox/addon/selite-selblocks-global/',
17 | requisitePlugins: {
18 | 'testcase-debug-context@selite.googlecode.com': {
19 | name: 'SeLite TestCase Debug Context',
20 | infoURL: 'https://addons.mozilla.org/en-US/firefox/addon/selite-testcase-debug-conte/',
21 | minVersion: '0.76'
22 | },
23 | 'misc@selite.googlecode.com': {
24 | name: 'SeLite Miscellaneous',
25 | infoURL: 'https://addons.mozilla.org/en-US/firefox/addon/selite-miscellaneous/',
26 | minVersion: '0.87'
27 | }
28 | }
29 | } );
30 |
--------------------------------------------------------------------------------
/setup_proxy.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #change dir to where this script is run from:
3 | cd "$( dirname "${BASH_SOURCE[0]}" )"
4 |
5 | # Based on https://developer.mozilla.org/en/Setting_up_extension_development_environment and http://kb.mozillazine.org/Profile_folder_-_Firefox
6 | # This script accepts an optional parameter, which is a name of Firefox profile. Otherwise it uses 'default' profile. Either way, the profile must have been created by Firefox (i.e. its folder name must be in standard format).
7 | if [[ "$1" ]]
8 | then
9 | PROFILE="$1"
10 | else
11 | PROFILE=default
12 | fi
13 | HOME_FOLDER=~
14 |
15 | cd sel-blocks-fx_xpi
16 |
17 | if [ "$(uname)" == "Darwin" ]; then
18 | # According to http://kb.mozillazine.org/Profile_folder_-_Firefox there are two places for Firefox profile folder on Mac OS:
19 | # ~/Library/Mozilla/Firefox/Profiles/ or ~/Library/Application Support/Firefox/Profiles/
20 | # But on Mac OS 10.5.8 and 10.9.1 I could see the second folder only. If you can test both, please update this/send this to me.
21 | EXTENSION_FOLDER="$( echo "$HOME_FOLDER/Library/Application Support/Firefox/Profiles"/*.$PROFILE )"
22 | else
23 | EXTENSION_FOLDER="$( echo "$HOME_FOLDER/.mozilla/firefox/"*.$PROFILE )"
24 | fi
25 | EXTENSION_FOLDER=$EXTENSION_FOLDER/extensions
26 |
27 | # If you haven't got any extensions in Firefox profile yet, there is no 'extensions' folder. So create it.
28 | if [ ! -e "$EXTENSION_FOLDER" ]
29 | then
30 | mkdir "$EXTENSION_FOLDER"
31 | fi
32 |
33 | if [ ! -e "$EXTENSION_FOLDER"/selblocks-global\@selite.googlecode.com.xpi ]
34 | then
35 | pwd > "$EXTENSION_FOLDER"/selblocks-global@selite.googlecode.com
36 | fi
37 |
38 |
--------------------------------------------------------------------------------
/sel-blocksTests/try01 - no-op try.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try01
9 |
10 |
11 |
12 |
13 | try01
14 |
15 |
16 | log
17 | "-- no-op try --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | t-noop
39 |
40 |
41 |
42 | emit
43 | "trying"
44 |
45 |
46 |
47 | endTry
48 | t-noop
49 |
50 |
51 |
52 |
53 | assertEval
54 | selblocks.tcf.nestingLevel
55 | -1
56 |
57 |
58 | emit
59 | "/])"
60 |
61 |
62 |
63 | assertEmitted
64 | "([/~trying~/])"
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/sel-blocksTests/branching01.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | branching01
8 |
9 |
10 |
11 |
12 | branching01
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | emit
21 | "BEFORE"
22 |
23 |
24 |
25 | goto
26 | HERE
27 |
28 |
29 |
30 | emit
31 | "A"
32 |
33 |
34 |
35 | label
36 | HERE
37 |
38 |
39 |
40 | gotoIf
41 | true
42 | THERE
43 |
44 |
45 | emit
46 | "B"
47 |
48 |
49 |
50 | label
51 | THERE
52 |
53 |
54 |
55 | skipNext
56 |
57 |
58 |
59 |
60 | emit
61 | "C"
62 |
63 |
64 |
65 | emit
66 | "AFTER"
67 |
68 |
69 |
70 | assertEmitted
71 | "BEFORE~AFTER"
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/sel-blocksTests/function05-scoping-issue5.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | function05-scoping-issue5
8 |
9 |
10 |
11 |
12 | function05-scoping-issue5
13 |
14 |
15 | store
16 | 'void'
17 | variable
18 |
19 |
20 | call
21 | outer
22 | variable='Hello'
23 |
24 |
25 | function
26 | outer
27 | variable
28 |
29 |
30 | call
31 | inner
32 |
33 |
34 |
35 | log
36 | "after variable=" + variable
37 |
38 |
39 |
40 | endFunction
41 |
42 |
43 |
44 |
45 |
46 | function
47 | inner
48 |
49 |
50 |
51 | log
52 | "variable=" + variable
53 |
54 |
55 |
56 | store
57 | 'bye bye'
58 | variable
59 |
60 |
61 | endFunction
62 |
63 |
64 |
65 |
66 | log
67 | "done variable=" + variable
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/sel-blocksTests/forxml.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | forxml
8 |
9 |
10 |
11 |
12 | forxml
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | deleteVars
21 | xname
22 |
23 |
24 |
25 | emit
26 | "START ${xname}"
27 |
28 |
29 |
30 |
31 | forXml
32 | http://refactoror.net/forxml.xml
33 |
34 |
35 |
36 | emit
37 | xname
38 |
39 |
40 |
41 | endForXml
42 |
43 |
44 |
45 |
46 | emit
47 | "INTERMISSION ${xname}"
48 |
49 |
50 |
51 |
52 | loadXmlVars
53 | http://refactoror.net/forxml.xml
54 | xname == "dogbert"
55 |
56 |
57 | emit
58 | "END ${xname}"
59 |
60 |
61 |
62 |
63 | assertEmitted
64 | "START $" + "{xname}~dilbert~dogbert~wally~INTERMISSION $" + "{xname}~END dogbert"
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/selenese-scripts/various/iterate_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | iterate_case
8 |
9 |
10 |
11 |
12 | iterate
13 |
14 |
15 | storeEval
16 | ["hi", "mate"][Symbol.iterator]()
17 | itr
18 |
19 |
20 | forIterator
21 | value
22 | ["hi", "mate"][Symbol.iterator]()
23 |
24 |
25 | log
26 | ${value}
27 | warn
28 |
29 |
30 | endForIterator
31 |
32 |
33 |
34 |
35 |
36 | forIterator
37 | value
38 | ["hi", "mate"][Symbol.iterator]()
39 |
40 |
41 | log
42 | ${value}
43 | warn
44 |
45 |
46 | endForIterator
47 |
48 |
49 |
50 |
51 |
52 | forIterable
53 | value
54 | ["hi", "mate"]
55 |
56 |
57 | log
58 | ${value}
59 | warn
60 |
61 |
62 | endForIterable
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/sel-blocksTests/forjson.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | forjson
8 |
9 |
10 |
11 |
12 | forjson
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | deleteVars
21 | jname
22 |
23 |
24 |
25 | emit
26 | "START ${jname}"
27 |
28 |
29 |
30 |
31 | forJson
32 | http://refactoror.net/forjson.json
33 |
34 |
35 |
36 | emit
37 | jname
38 |
39 |
40 |
41 | endForJson
42 |
43 |
44 |
45 |
46 | emit
47 | "INTERMISSION ${jname}"
48 |
49 |
50 |
51 |
52 | loadJsonVars
53 | http://refactoror.net/forjson.json
54 | jname == "dogbert"
55 |
56 |
57 | emit
58 | "END ${jname}"
59 |
60 |
61 |
62 |
63 | assertEmitted
64 | "START $" + "{jname}~dilbert~dogbert~wally~INTERMISSION $" + "{jname}~END dogbert"
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/selenese-scripts/various/whilePromise_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | whilePromise_case
8 |
9 |
10 |
11 |
12 | whilePromise_case
13 |
14 |
15 | storeEval
16 | 0
17 | numberOfLoopRuns
18 |
19 |
20 | whilePromise
21 | new Promise( resolve => window.setTimeout( ()=>resolve($numberOfLoopRuns===0), Math.min(150, selenium.defaultTimeout-150) ) )
22 |
23 |
24 |
25 | getEval
26 | $numberOfLoopRuns++
27 |
28 |
29 |
30 | endWhilePromise
31 |
32 |
33 |
34 |
35 | assertEval
36 | $numberOfLoopRuns
37 | 1
38 |
39 |
40 |
41 | whilePromise
42 | new Promise( resolve => window.setTimeout( ()=>resolve($numberOfLoopRuns<4), Math.min(150, selenium.defaultTimeout-150) ) )
43 |
44 |
45 |
46 | getEval
47 | $numberOfLoopRuns++
48 |
49 |
50 |
51 | endWhilePromise
52 |
53 |
54 |
55 |
56 | assertEval
57 | $numberOfLoopRuns
58 | 4
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/sel-blocksTests/continue-break01.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | continue-break01
8 |
9 |
10 |
11 |
12 | continue-break01
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | deleteVars
21 | f
22 |
23 |
24 |
25 | for
26 | f=3; f <= 9; f++
27 |
28 |
29 |
30 | continue
31 | f == 6
32 |
33 |
34 |
35 | if
36 | f > 6
37 |
38 |
39 |
40 | if
41 | f == 7
42 |
43 |
44 |
45 | continue
46 |
47 |
48 |
49 |
50 | else
51 |
52 |
53 |
54 |
55 | break
56 |
57 |
58 |
59 |
60 | endIf
61 |
62 |
63 |
64 |
65 | endIf
66 |
67 |
68 |
69 |
70 | emit
71 | "iter=${f}"
72 |
73 |
74 |
75 | endFor
76 |
77 |
78 |
79 |
80 |
81 | assertEmitted
82 | "iter=3~iter=4~iter=5"
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/sel-blocksTests/try02 - try-finally, w-no error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try02
9 |
10 |
11 |
12 |
13 | try02
14 |
15 |
16 | log
17 | "-- try/finally, w/no error --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | t-fin
39 |
40 |
41 |
42 | emit
43 | "trying"
44 |
45 |
46 |
47 | finally
48 |
49 |
50 |
51 |
52 | emit
53 | "finally"
54 |
55 |
56 |
57 | endTry
58 |
59 |
60 |
61 |
62 |
63 | assertEval
64 | selblocks.tcf.nestingLevel
65 | -1
66 |
67 |
68 | emit
69 | "/])"
70 |
71 |
72 |
73 | assertEmitted
74 | "([/~trying~finally~/])"
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/sel-blocksTests/foreach-xpath.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | foreach-xpath
8 |
9 |
10 |
11 |
12 | foreach-xpath
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | echo
21 | $x("//input")
22 |
23 |
24 |
25 | echo
26 | $X("//input")
27 |
28 |
29 |
30 | echo
31 | begin
32 |
33 |
34 |
35 | emit
36 | "START ${_i}) ${link}"
37 |
38 |
39 |
40 | foreach
41 | link
42 | $X("//input")
43 |
44 |
45 | emit
46 | "${_i}) ${link}"
47 |
48 |
49 |
50 | echo
51 | ${link}
52 |
53 |
54 |
55 | endForeach
56 |
57 |
58 |
59 |
60 | emit
61 | "END ${_i}) ${link}"
62 |
63 |
64 |
65 | assertEmitted
66 | "START ${" + "_i}) ${" + "link}~0) [object HTMLInputElement]~1) [object HTMLInputElement]~2) [object HTMLInputElement]~END ${" + "_i}) ${" + "link}"
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/selenese-scripts/various/try_catch_function_calls_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | try_catch_function_calls_case
8 |
9 |
10 |
11 |
12 | try_catch_function_calls_case
13 |
14 |
15 | if
16 | false
17 |
18 |
19 |
20 | getEval
21 | throw new Error( "This shouldn't be called" );
22 |
23 |
24 |
25 | endIf
26 |
27 |
28 |
29 |
30 |
31 | getEval
32 | storedVars.errorThrownFromFunction= undefined
33 |
34 |
35 |
36 | try
37 |
38 |
39 |
40 |
41 | call
42 | throwAnError
43 |
44 |
45 |
46 | catch
47 |
48 |
49 |
50 |
51 | storeEval
52 | true
53 | errorThrownFromFunction
54 |
55 |
56 | endTry
57 |
58 |
59 |
60 |
61 | getEval
62 | if( !storedVars.errorThrownFromFunction) { throw new Error( "try_catch_function_calls_case: function throwAnError should have thrown an error that should have been caught." ); }
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/sel-blocksTests/while.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | while
8 |
9 |
10 |
11 |
12 | while
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | deleteVars
21 | w
22 |
23 |
24 |
25 | store
26 | 3
27 | w
28 |
29 |
30 | emit
31 | "START: ${w}"
32 |
33 |
34 |
35 |
36 | while
37 | w == 42
38 |
39 |
40 |
41 | emit
42 | "SHOULD NEVER HAPPEN"
43 |
44 |
45 |
46 | endWhile
47 |
48 |
49 |
50 |
51 |
52 | while
53 | w > 0
54 |
55 |
56 |
57 | emit
58 | "iter=${w}"
59 |
60 |
61 |
62 | storeEval
63 | ${w}-1
64 | w
65 |
66 |
67 | endWhile
68 |
69 |
70 |
71 |
72 | emit
73 | "END: ${w}"
74 |
75 |
76 |
77 |
78 | assertEmitted
79 | "START: 3~iter=3~iter=2~iter=1~END: 0"
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/sel-blocksTests/try03 - try-catch, but no error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try03
9 |
10 |
11 |
12 |
13 | try03
14 |
15 |
16 | log
17 | "-- try/catch, but no error --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | tc0
39 |
40 |
41 |
42 | emit
43 | "trying"
44 |
45 |
46 |
47 | catch
48 |
49 |
50 |
51 |
52 | assertEval
53 | "should NEVER enter this catch block due to no error"
54 |
55 |
56 |
57 | endTry
58 |
59 |
60 |
61 |
62 |
63 | assertEval
64 | selblocks.tcf.nestingLevel
65 | -1
66 |
67 |
68 | emit
69 | "/])"
70 |
71 |
72 |
73 | assertEmitted
74 | "([/~trying~/])"
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/selenese-scripts-negative/successful_try_then_failed_assert.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | successful_try_then_failed_assert
8 |
9 |
10 |
11 |
12 | successful_try_then_failed_assert
13 |
14 |
15 |
16 | function
17 | clickAtNonExistingItem
18 |
19 |
20 |
21 | click
22 | NonExistingItem
23 |
24 |
25 |
26 |
27 | endFunction
28 |
29 |
30 |
31 |
32 |
33 | if
34 | true
35 |
36 |
37 |
38 | try
39 |
40 |
41 |
42 |
43 | call
44 | clickAtNonExistingItem
45 |
46 |
47 |
48 | catch
49 |
50 |
51 |
52 |
53 | endTry
54 |
55 |
56 |
57 |
58 | endIf
59 |
60 |
61 |
62 |
63 |
64 | assertEval
65 | false
66 | thisWillFail
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/sel-blocksTests/if03.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | if03
8 |
9 |
10 |
11 |
12 | if03
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 |
21 | foreach
22 | i
23 | 2, 0, 1, 4, 3, 5
24 |
25 |
26 | if
27 | i == 0
28 |
29 |
30 |
31 | emit
32 | "if-${i}"
33 |
34 |
35 |
36 | elseIf
37 | i == 1
38 |
39 |
40 |
41 | emit
42 | "elseIf-${i}"
43 |
44 |
45 |
46 | elseIf
47 | i == 2
48 |
49 |
50 |
51 | emit
52 | "elseIf-${i}"
53 |
54 |
55 |
56 | elseIf
57 | i == 3
58 |
59 |
60 |
61 | emit
62 | "elseIf-${i}"
63 |
64 |
65 |
66 | else
67 |
68 |
69 |
70 |
71 | emit
72 | "else-${i}"
73 |
74 |
75 |
76 | endIf
77 |
78 |
79 |
80 |
81 | endForeach
82 |
83 |
84 |
85 |
86 | assertEmitted
87 | "elseIf-2~if-0~elseIf-1~else-4~elseIf-3~else-5"
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/sel-blocksTests/try04 - catch specific error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try04
9 |
10 |
11 |
12 |
13 | try04
14 |
15 |
16 | log
17 | "-- catch specific error --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | tc1
39 |
40 |
41 |
42 | throw
43 | "blamo catch ALL"
44 |
45 |
46 |
47 | assertEval
48 | "this command should not be reached, due to thrown"
49 |
50 |
51 |
52 | catch
53 |
54 |
55 |
56 |
57 | emit
58 | "caught '" + _error.message + "'"
59 |
60 |
61 |
62 | endTry
63 |
64 |
65 |
66 |
67 |
68 | assertEval
69 | selblocks.tcf.nestingLevel
70 | -1
71 |
72 |
73 | emit
74 | "/])"
75 |
76 |
77 |
78 | assertEmitted
79 | "([/~caught 'blamo catch ALL'~/])"
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/sel-blocksTests/try21 - catch failed verify command.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try21
9 |
10 |
11 |
12 |
13 | try21
14 |
15 |
16 | log
17 | "-- catch failed verify command --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | tcv1
39 |
40 |
41 |
42 | verifyEval
43 | 1
44 | 2
45 |
46 |
47 | assertEval
48 | "this command should not be reached, due to failed verify"
49 |
50 |
51 |
52 | catch
53 |
54 |
55 |
56 |
57 | emit
58 | "caught '" + _error.message + "'"
59 |
60 |
61 |
62 | endTry
63 |
64 |
65 |
66 |
67 |
68 | assertEval
69 | selblocks.tcf.nestingLevel
70 | -1
71 |
72 |
73 | emit
74 | "/])"
75 |
76 |
77 |
78 | assertEmitted
79 | "([/~caught 'Actual value '1' did not match '2''~/])"
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/sel-blocksTests/try22 - exitTest w-finally processing.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try22
9 |
10 |
11 |
12 |
13 | try22
14 |
15 |
16 | log
17 | "-- exitTest w/finally processing --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | abort
39 |
40 |
41 |
42 | emit
43 | "trying"
44 |
45 |
46 |
47 | emit
48 | "exitTest ..."
49 |
50 |
51 |
52 | exitTest
53 |
54 |
55 |
56 |
57 | finally
58 |
59 |
60 |
61 |
62 | emit
63 | "finallying"
64 |
65 |
66 |
67 | assertEmitted
68 | "([/~trying~exitTest ...~finallying"
69 |
70 |
71 |
72 | resetEmitted
73 |
74 |
75 |
76 |
77 | endTry
78 | abort
79 |
80 |
81 |
82 |
83 | assertEval
84 | "this command should not be reached, due to exitTest above"
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/sel-blocksTests/negativeTests/try01 - try without matching catch.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try
9 |
10 |
11 |
12 |
13 | try
14 |
15 |
16 | log
17 | "-- try without matching catch --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | assertEval
27 | selblocks.tcf.nestingLevel
28 | -1
29 |
30 |
31 |
32 | try
33 | miss
34 |
35 |
36 |
37 | assertEval
38 | true
39 | true
40 |
41 |
42 | throw
43 | "blamo will NOT be caught at all"
44 |
45 |
46 |
47 | assertEval
48 | "this command should not be reached"
49 |
50 |
51 |
52 | catch
53 | /will NOT catch it/
54 |
55 |
56 |
57 | log
58 | "caught miss '" + _error.message + "'"
59 |
60 |
61 |
62 | finally
63 |
64 |
65 |
66 |
67 | log
68 | "finally"
69 |
70 |
71 |
72 | endTry
73 | miss
74 |
75 |
76 |
77 |
78 | assertEval
79 | selblocks.tcf.nestingLevel
80 | -1
81 |
82 |
83 | emit
84 | "trying"
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/selenese-scripts/various/assertFunctionFailure_def_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | assertFunctionFailure_def_case
8 |
9 |
10 |
11 |
12 | assertFunctionFailure_def_case
13 |
14 |
15 | function
16 | assertFunctionFailure
17 | func
18 |
19 |
20 | getEval
21 | $hasFailed= false
22 |
23 |
24 |
25 | try
26 |
27 |
28 |
29 |
30 | call
31 | ${func}
32 |
33 |
34 |
35 | catch
36 |
37 |
38 |
39 |
40 | getEval
41 | $hasFailed= true
42 |
43 |
44 |
45 | endTry
46 |
47 |
48 |
49 |
50 | assertEval
51 | $hasFailed
52 | true
53 |
54 |
55 | endFunction
56 |
57 |
58 |
59 |
60 |
61 |
62 | function
63 | assertFunctionFailure_test
64 |
65 |
66 |
67 | getEval
68 | throw new Error('test')
69 | regexp:1
70 |
71 |
72 | endFunction
73 |
74 |
75 |
76 |
77 | call
78 | assertFunctionFailure
79 | func='assertFunctionFailure_test'
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/selenese-scripts/call-back/selenese_functions_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | New Test
8 |
9 |
10 |
11 |
12 | New Test
13 |
14 |
15 | function
16 | assertReceivedParameters
17 | a, b
18 |
19 |
20 | assertEval
21 | typeof $a!=='undefined'
22 | true
23 |
24 |
25 | assertEval
26 | typeof $b!=='undefined'
27 | true
28 |
29 |
30 | endFunction
31 |
32 |
33 |
34 |
35 |
36 | function
37 | func
38 | shouldFail
39 |
40 |
41 | getEval
42 | if( $shouldFail ) throw new Error(storedVars.shouldFail)
43 |
44 |
45 |
46 | return
47 | "success"
48 |
49 |
50 |
51 | endFunction
52 |
53 |
54 |
55 |
56 |
57 | function
58 | funcThatDoesntThrow
59 | shouldFail
60 |
61 |
62 | try
63 |
64 |
65 |
66 |
67 | getEval
68 | if( $shouldFail ) throw new Error($shouldFail)
69 |
70 |
71 |
72 | getEval
73 | alert( "from Selenese function funcThatDoesntThrow" )
74 |
75 |
76 |
77 | catch
78 | /.*/
79 |
80 |
81 |
82 | finally
83 |
84 |
85 |
86 |
87 | endTry
88 |
89 |
90 |
91 |
92 | endFunction
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/sel-blocksTests/function01.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | function01
8 |
9 |
10 |
11 |
12 | function01
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | deleteVars
21 | sname, srole
22 |
23 |
24 |
25 | emit
26 | "START ${sname} ${srole}"
27 |
28 |
29 |
30 |
31 | call
32 | doSomething
33 | sname = "dilbert,Q", srole = "goof"
34 |
35 |
36 |
37 | function
38 | doSomething
39 | sname
40 |
41 |
42 | emit
43 | "sname=${sname},srole=${srole}"
44 |
45 |
46 |
47 | endFunction
48 | doSomething
49 |
50 |
51 |
52 |
53 | call
54 | doSomething
55 | sname = "dogbert", srole = "woof"
56 |
57 |
58 | call
59 | doSomething
60 | sname = "ratbert", srole = "squeak"
61 |
62 |
63 |
64 | foreach
65 | sname
66 | "asok", "alice"
67 |
68 |
69 | call
70 | doSomething
71 | sname = sname, srole = "super=user"
72 |
73 |
74 | endForeach
75 |
76 |
77 |
78 |
79 | emit
80 | "DONE ${sname} ${srole}"
81 |
82 |
83 |
84 |
85 | assertEmitted
86 | "START $" + "{sname} $" + "{srole}~sname=dilbert,Q,srole=goof~sname=dogbert,srole=woof~sname=ratbert,srole=squeak~sname=asok,srole=super=user~sname=alice,srole=super=user~DONE $" + "{sname} $" + "{srole}"
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/sel-blocksTests/try15 - command bubbling, intra-try break.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try15
9 |
10 |
11 |
12 |
13 | try15
14 |
15 |
16 | log
17 | "-- command bubbling, intra-try break --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | breaker
39 |
40 |
41 |
42 | emit
43 | "trying"
44 |
45 |
46 |
47 | emit
48 | "while'g"
49 |
50 |
51 |
52 | for
53 | w=3; w > 0; w--
54 |
55 |
56 |
57 | if
58 | w==2
59 |
60 |
61 |
62 | emit
63 | "${w}) BREAK"
64 |
65 |
66 |
67 | break
68 |
69 |
70 |
71 |
72 | endIf
73 |
74 |
75 |
76 |
77 | emit
78 | "${w}) iterating"
79 |
80 |
81 |
82 | endFor
83 |
84 |
85 |
86 |
87 | finally
88 |
89 |
90 |
91 |
92 | emit
93 | "finallying"
94 |
95 |
96 |
97 | endTry
98 | breaker
99 |
100 |
101 |
102 |
103 | assertEval
104 | selblocks.tcf.nestingLevel
105 | -1
106 |
107 |
108 | emit
109 | "/])"
110 |
111 |
112 |
113 | assertEmitted
114 | "([/~trying~while'g~3) iterating~2) BREAK~finallying~/])"
115 |
116 |
117 |
118 |
119 |
120 |
--------------------------------------------------------------------------------
/sel-blocksTests/try17 - command bubbling, intra-try continue.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try17
9 |
10 |
11 |
12 |
13 | try17
14 |
15 |
16 | log
17 | "-- command bubbling, intra-try continue --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | continuer
39 |
40 |
41 |
42 | emit
43 | "trying"
44 |
45 |
46 |
47 | emit
48 | "while'g"
49 |
50 |
51 |
52 | for
53 | w=3; w > 0; w--
54 |
55 |
56 |
57 | if
58 | w==2
59 |
60 |
61 |
62 | emit
63 | "${w}) CONTINUE"
64 |
65 |
66 |
67 | continue
68 |
69 |
70 |
71 |
72 | endIf
73 |
74 |
75 |
76 |
77 | emit
78 | "${w}) iterating"
79 |
80 |
81 |
82 | endFor
83 |
84 |
85 |
86 |
87 | finally
88 |
89 |
90 |
91 |
92 | emit
93 | "finallying"
94 |
95 |
96 |
97 | endTry
98 | continuer
99 |
100 |
101 |
102 |
103 | assertEval
104 | selblocks.tcf.nestingLevel
105 | -1
106 |
107 |
108 | emit
109 | "/])"
110 |
111 |
112 |
113 | assertEmitted
114 | "([/~trying~while'g~3) iterating~2) CONTINUE~1) iterating~finallying~/])"
115 |
116 |
117 |
118 |
119 |
120 |
--------------------------------------------------------------------------------
/sel-blocksTests/try14 - command bubbling, break wfinally.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try14
9 |
10 |
11 |
12 |
13 | try14
14 |
15 |
16 | log
17 | "-- command bubbling, break w/finally --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | emit
32 | "while'g"
33 |
34 |
35 |
36 | for
37 | w=3; w > 0; w--
38 |
39 |
40 |
41 | assertEval
42 | selblocks.tcf.nestingLevel
43 | -1
44 |
45 |
46 |
47 | try
48 | breaker
49 |
50 |
51 |
52 | emit
53 | "${w}) trying"
54 |
55 |
56 |
57 | if
58 | w==2
59 |
60 |
61 |
62 | emit
63 | "${w}) BREAK"
64 |
65 |
66 |
67 | break
68 |
69 |
70 |
71 |
72 | endIf
73 |
74 |
75 |
76 |
77 | finally
78 |
79 |
80 |
81 |
82 | emit
83 | "${w}) finallying"
84 |
85 |
86 |
87 | endTry
88 | breaker
89 |
90 |
91 |
92 |
93 | assertEval
94 | selblocks.tcf.nestingLevel
95 | -1
96 |
97 |
98 | emit
99 | "${w}) iterating"
100 |
101 |
102 |
103 | endFor
104 |
105 |
106 |
107 |
108 | emit
109 | "/])"
110 |
111 |
112 |
113 | assertEmitted
114 | "([/~while'g~3) trying~3) finallying~3) iterating~2) trying~2) BREAK~2) finallying~/])"
115 |
116 |
117 |
118 |
119 |
120 |
--------------------------------------------------------------------------------
/sel-blocksTests/try16 - command bubbling, continue w-finally.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try16
9 |
10 |
11 |
12 |
13 | try16
14 |
15 |
16 | log
17 | "-- command bubbling, continue w/finally --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | emit
32 | "while'g"
33 |
34 |
35 |
36 | for
37 | w=3; w > 0; w--
38 |
39 |
40 |
41 | assertEval
42 | selblocks.tcf.nestingLevel
43 | -1
44 |
45 |
46 |
47 | try
48 | continuer
49 |
50 |
51 |
52 | emit
53 | "${w}) trying"
54 |
55 |
56 |
57 | if
58 | w==2
59 |
60 |
61 |
62 | emit
63 | "${w}) CONTINUE"
64 |
65 |
66 |
67 | continue
68 |
69 |
70 |
71 |
72 | endIf
73 |
74 |
75 |
76 |
77 | finally
78 |
79 |
80 |
81 |
82 | emit
83 | "${w}) finallying"
84 |
85 |
86 |
87 | endTry
88 | continuer
89 |
90 |
91 |
92 |
93 | assertEval
94 | selblocks.tcf.nestingLevel
95 | -1
96 |
97 |
98 | emit
99 | "${w}) iterating"
100 |
101 |
102 |
103 | endFor
104 |
105 |
106 |
107 |
108 | emit
109 | "/])"
110 |
111 |
112 |
113 | assertEmitted
114 | "([/~while'g~3) trying~3) finallying~3) iterating~2) trying~2) CONTINUE~2) finallying~1) trying~1) finallying~1) iterating~/])"
115 |
116 |
117 |
118 |
119 |
120 |
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/content/extensions/logger.js:
--------------------------------------------------------------------------------
1 | // Based on traditional SelBlocks, with clarifications and without unneeded Logger.trace().
2 | "use strict";
3 |
4 | // Following assignments is purely for JSDoc.
5 | /** @namespace */
6 | selblocks= selblocks;
7 |
8 | /** LOG wrapper for SelBlocks-specific behavior
9 | * @class
10 | */
11 | selblocks.Logger= function Logger() {};
12 | /** Log an error. */
13 | selblocks.Logger.prototype.error = function (msg) { this.logit("error", msg); };
14 | /** Log a warning. */
15 | selblocks.Logger.prototype.warn = function (msg) { this.logit("warn", msg); };
16 | /** Log at info level. */
17 | selblocks.Logger.prototype.info = function (msg) { this.logit("info", msg); };
18 | /** Log at debug level. */
19 | selblocks.Logger.prototype.debug = function (msg) { this.logit("debug", msg); };
20 |
21 | /** Log at given level. */
22 | selblocks.Logger.prototype.logit = function (logLevel, msg) {
23 | // Following LOG is a global object from Selenium IDE. It's different to selblocks.LOG.
24 | LOG[logLevel]("[" + $$.name + "] " + msg); // call the Selenium logger
25 | };
26 |
27 | // ==================== Stack Tracer ====================
28 | /** Generate stack trace.
29 | * @param {Error|undefined} [err]
30 | * @returns {Array} */
31 | selblocks.Logger.prototype.genStackTrace = function(err)
32 | {
33 | var e = err || new Error();
34 | var stackTrace = [];
35 | if (!e.stack)
36 | stackTrace.push("No stack trace, (Firefox only)");
37 | else {
38 | var funcCallPattern = /^\s*[A-Za-z0-9\-_\$]+\(/;
39 | var lines = e.stack.split("\n");
40 | for (var i=0; i < lines.length; i++) {
41 | if (lines[i].match(funcCallPattern))
42 | stackTrace.push(lines[i]);
43 | }
44 | if (!err)
45 | stackTrace.shift(); // remove the call to genStackTrace() itself
46 | }
47 | return stackTrace;
48 | };
49 |
50 | /** Log stack trace.
51 | * @param {Error|undefined} [err]
52 | */
53 | selblocks.Logger.prototype.logStackTrace = function(err)
54 | {
55 | var t = this.genStackTrace(err);
56 | if (!err)
57 | t.shift(); // remove the call to logStackTrace() itself
58 | this.warn("__Stack Trace__");
59 | for (var i = 0; i < t.length; i++) {
60 | this.warn("@@ " + t[i]);
61 | }
62 | };
63 |
64 | /** Describe the calling function.
65 | */
66 | selblocks.Logger.prototype.descCaller = function()
67 | {
68 | var t = this.genStackTrace(new Error());
69 | if (t.length == 0) return "no client function";
70 | t.shift(); // remove the call to descCaller() itself
71 | if (t.length == 0) return "no caller function";
72 | t.shift(); // remove the call to client function
73 | if (t.length == 0) return "undefined caller function";
74 | return "caller: " + t[0];
75 | };
76 |
77 | /** @member {Logger} */
78 | selblocks.LOG = new selblocks.Logger();
79 |
--------------------------------------------------------------------------------
/selenese-scripts/various/repeat_until_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | repeat_until_case
8 |
9 |
10 |
11 |
12 | repeat_until_case
13 |
14 |
15 | storeEval
16 | 0
17 | numberOfLoopRuns
18 |
19 |
20 | repeat
21 |
22 |
23 |
24 |
25 | getEval
26 | $numberOfLoopRuns++
27 |
28 |
29 |
30 | until
31 | true
32 |
33 |
34 |
35 | assertEval
36 | $numberOfLoopRuns
37 | 1
38 |
39 |
40 |
41 | repeat
42 |
43 |
44 |
45 |
46 | getEval
47 | $numberOfLoopRuns++
48 |
49 |
50 |
51 | until
52 | $numberOfLoopRuns>=4
53 |
54 |
55 |
56 | assertEval
57 | $numberOfLoopRuns
58 | 4
59 |
60 |
61 |
62 | storeEval
63 | 0
64 | numberOfLoopRuns
65 |
66 |
67 | repeatPromise
68 |
69 |
70 |
71 |
72 | getEval
73 | $numberOfLoopRuns++
74 |
75 |
76 |
77 |
78 | untilPromise
79 | new Promise( resolve => window.setTimeout( ()=>{debugger;resolve(true)}, Math.min(150, selenium.defaultTimeout-150) ) )
80 |
81 |
82 |
83 | assertEval
84 | $numberOfLoopRuns
85 | 1
86 |
87 |
88 |
89 | repeatPromise
90 |
91 |
92 |
93 |
94 | getEval
95 | $numberOfLoopRuns++
96 |
97 |
98 |
99 | untilPromise
100 | new Promise( resolve => window.setTimeout( ()=>{debugger;resolve($numberOfLoopRuns>=4)}, Math.min(150, selenium.defaultTimeout-150) ) )
101 |
102 |
103 |
104 | assertEval
105 | $numberOfLoopRuns
106 | 4
107 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/sel-blocksTests/try18 - command bubbling, error replaced by return.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try18
9 |
10 |
11 |
12 |
13 | try18
14 |
15 |
16 | log
17 | "-- command bubbling, error replaced by return --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | emit
32 | "calling"
33 |
34 |
35 |
36 | call
37 | cmdBubA
38 |
39 |
40 |
41 | emit
42 | "returned ${_result}"
43 |
44 |
45 |
46 | function
47 | cmdBubA
48 |
49 |
50 |
51 | emit
52 | "in cmdBubA"
53 |
54 |
55 |
56 | assertEval
57 | selblocks.tcf.nestingLevel
58 | -1
59 |
60 |
61 |
62 | try
63 | cmdBub-tcf
64 |
65 |
66 |
67 | emit
68 | "trying"
69 |
70 |
71 |
72 | emit
73 | "returning (1)"
74 |
75 |
76 |
77 | return
78 | 1
79 |
80 |
81 |
82 | finally
83 |
84 |
85 |
86 |
87 | emit
88 | "finallying"
89 |
90 |
91 |
92 | emit
93 | "returning (2)"
94 |
95 |
96 |
97 | return
98 | 2
99 |
100 |
101 |
102 | endTry
103 |
104 |
105 |
106 |
107 |
108 | assertEval
109 | "this command should not be reached, due to return/return above"
110 |
111 |
112 |
113 | endFunction
114 |
115 |
116 |
117 |
118 | emit
119 | "/])"
120 |
121 |
122 |
123 | assertEmitted
124 | "([/~calling~in cmdBubA~trying~returning (1)~finallying~returning (2)~returned 2~/])"
125 |
126 |
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/sel-blocksTests/try19 - command bubbling, error replaced by throw.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try19
9 |
10 |
11 |
12 |
13 | try19
14 |
15 |
16 | log
17 | "-- command bubbling, error replaced by return --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | emit
32 | "calling"
33 |
34 |
35 |
36 | call
37 | cmdBubB
38 |
39 |
40 |
41 | emit
42 | "returned ${_result}"
43 |
44 |
45 |
46 | function
47 | cmdBubB
48 |
49 |
50 |
51 | emit
52 | "in cmdBubB"
53 |
54 |
55 |
56 | assertEval
57 | selblocks.tcf.nestingLevel
58 | -1
59 |
60 |
61 |
62 | try
63 | cmdBub-tcf
64 |
65 |
66 |
67 | emit
68 | "trying"
69 |
70 |
71 |
72 | emit
73 | "throwing"
74 |
75 |
76 |
77 | throw
78 | "short-lived error"
79 |
80 |
81 |
82 | finally
83 |
84 |
85 |
86 |
87 | emit
88 | "finallying"
89 |
90 |
91 |
92 | emit
93 | "returning (2)"
94 |
95 |
96 |
97 | return
98 | 2
99 |
100 |
101 |
102 | endTry
103 |
104 |
105 |
106 |
107 |
108 | assertEval
109 | "this command should not be reached, due to throw/return above"
110 |
111 |
112 |
113 | endFunction
114 |
115 |
116 |
117 |
118 | emit
119 | "/])"
120 |
121 |
122 |
123 | assertEmitted
124 | "([/~calling~in cmdBubB~trying~throwing~finallying~returning (2)~returned 2~/])"
125 |
126 |
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/sel-blocksTests/nested-loops.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | nested-loops
8 |
9 |
10 |
11 |
12 | nested-loops
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | deleteVars
21 | i, n, uname
22 |
23 |
24 |
25 | startTimer
26 |
27 |
28 |
29 |
30 | store
31 | 2
32 | i
33 |
34 |
35 | emit
36 | "START ${i}"
37 |
38 |
39 |
40 | while
41 | i > 0
42 |
43 |
44 |
45 | emit
46 | "while=${i}"
47 |
48 |
49 |
50 | foreach
51 | uname
52 | "dilbert", "dogbert"
53 |
54 |
55 | emit
56 | "foreach=${uname}"
57 |
58 |
59 |
60 | for
61 | n = 2; n <=3; n++
62 |
63 |
64 |
65 | emit
66 | "FOR=${n}"
67 |
68 |
69 |
70 | for
71 | n = 7; n <= 8; n++
72 |
73 |
74 |
75 | emit
76 | "for=${n}"
77 |
78 |
79 |
80 | endFor
81 |
82 |
83 |
84 |
85 | endFor
86 |
87 |
88 |
89 |
90 | emit
91 | "endFor ${n}"
92 |
93 |
94 |
95 | endForeach
96 |
97 |
98 |
99 |
100 | storeEval
101 | ${i}-1
102 | i
103 |
104 |
105 | endWhile
106 |
107 |
108 |
109 |
110 | emit
111 | "END ${i}"
112 |
113 |
114 |
115 | timerElapsed
116 |
117 |
118 |
119 |
120 |
121 | assertEmitted
122 | "START 2~while=2~foreach=dilbert~FOR=2~for=7~for=8~FOR=3~for=7~for=8~endFor ${n}~foreach=dogbert~FOR=2~for=7~for=8~FOR=3~for=7~for=8~endFor ${n}~while=1~foreach=dilbert~FOR=2~for=7~for=8~FOR=3~for=7~for=8~endFor ${n}~foreach=dogbert~FOR=2~for=7~for=8~FOR=3~for=7~for=8~endFor ${n}~END 0"
123 |
124 |
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------
/sel-blocksTests/try07 - bubble up to catch ALL.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try07
9 |
10 |
11 |
12 |
13 | try07
14 |
15 |
16 | log
17 | "-- bubble up to catch ALL --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | t-all-outer
39 |
40 |
41 |
42 | emit
43 | "trying-outer"
44 |
45 |
46 |
47 | assertEval
48 | selblocks.tcf.nestingLevel
49 | 0
50 |
51 |
52 |
53 | try
54 | t-all-inner
55 |
56 |
57 |
58 | emit
59 | "trying"
60 |
61 |
62 |
63 | throw
64 | "blamo try-catch-finally"
65 |
66 |
67 |
68 | assertEval
69 | "this command should not be reached, due to throw"
70 |
71 |
72 |
73 | catch
74 | /will NOT catch it/
75 |
76 |
77 |
78 | emit
79 | "caught '" + _error.message + "'"
80 |
81 |
82 |
83 | endTry
84 | t-all-inner
85 |
86 |
87 |
88 |
89 | assertEval
90 | selblocks.tcf.nestingLevel
91 | 0
92 |
93 |
94 | catch
95 |
96 |
97 |
98 |
99 | emit
100 | "caught-outer '" + _error.message + "'"
101 |
102 |
103 |
104 | endTry
105 | t-all-outer
106 |
107 |
108 |
109 |
110 | assertEval
111 | selblocks.tcf.nestingLevel
112 | -1
113 |
114 |
115 | emit
116 | "/])"
117 |
118 |
119 |
120 | assertEmitted
121 | "([/~trying-outer~trying~caught-outer 'blamo try-catch-finally'~/])"
122 |
123 |
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/sel-blocksTests/try10 - bubble up to catch specific error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try10
9 |
10 |
11 |
12 |
13 | try10
14 |
15 |
16 | log
17 | "-- bubble up to catch specific error --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | bub-spec-outer
39 |
40 |
41 |
42 | emit
43 | "trying outer"
44 |
45 |
46 |
47 | assertEval
48 | selblocks.tcf.nestingLevel
49 | 0
50 |
51 |
52 |
53 | try
54 | bub-spec-inner
55 |
56 |
57 |
58 | emit
59 | "trying inner"
60 |
61 |
62 |
63 | assertEval
64 | selblocks.tcf.nestingLevel
65 | 1
66 |
67 |
68 | emit
69 | "throwing inner"
70 |
71 |
72 |
73 | throw
74 | "blamo"
75 |
76 |
77 |
78 | assertEval
79 | "this command should not be reached, due to throw"
80 |
81 |
82 |
83 | finally
84 |
85 |
86 |
87 |
88 | emit
89 | "finally"
90 |
91 |
92 |
93 | endTry
94 | bub-spec-inner
95 |
96 |
97 |
98 |
99 | catch
100 | /blamo/
101 |
102 |
103 |
104 | emit
105 | "caught '" + _error.message + "'"
106 |
107 |
108 |
109 | endTry
110 | bub-spec-outer
111 |
112 |
113 |
114 |
115 | assertEval
116 | selblocks.tcf.nestingLevel
117 | -1
118 |
119 |
120 | emit
121 | "/])"
122 |
123 |
124 |
125 | assertEmitted
126 | "([/~trying outer~trying inner~throwing inner~finally~caught 'blamo'~/])"
127 |
128 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/sel-blocksTests/try09 - bubble out of no-op try to catch specific error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try09
9 |
10 |
11 |
12 |
13 | try09
14 |
15 |
16 | log
17 | "-- bubble out of no-op try to catch specific error --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | noop-outer
39 |
40 |
41 |
42 | emit
43 | "trying outer"
44 |
45 |
46 |
47 | assertEval
48 | selblocks.tcf.nestingLevel
49 | 0
50 |
51 |
52 |
53 | try
54 | op-inner
55 |
56 |
57 |
58 | emit
59 | "trying inner"
60 |
61 |
62 |
63 | assertEval
64 | selblocks.tcf.nestingLevel
65 | 1
66 |
67 |
68 | emit
69 | "throwing inner"
70 |
71 |
72 |
73 | throw
74 | "blamo"
75 |
76 |
77 |
78 | assertEval
79 | "this command should not be reached, due to throw"
80 |
81 |
82 |
83 | endTry
84 | op-inner
85 |
86 |
87 |
88 |
89 | catch
90 | /blamo/
91 |
92 |
93 |
94 | emit
95 | "caught '" + _error.message + "'"
96 |
97 |
98 |
99 | finally
100 |
101 |
102 |
103 |
104 | emit
105 | "finally"
106 |
107 |
108 |
109 | endTry
110 | noop-outer
111 |
112 |
113 |
114 |
115 | assertEval
116 | selblocks.tcf.nestingLevel
117 | -1
118 |
119 |
120 | emit
121 | "/])"
122 |
123 |
124 |
125 | assertEmitted
126 | "([/~trying outer~trying inner~throwing inner~caught 'blamo'~finally~/])"
127 |
128 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/content/extensions/expression-parser.js:
--------------------------------------------------------------------------------
1 | /** Parse basic expressions.
2 | */
3 | "use strict";
4 |
5 | /** @namespace */
6 | selblocks.InfixExpressionParser= {
7 | _objname : "InfixExpressionParser"
8 | ,BRACKET_PAIRS : { "(": ")", "{": "}", "[": "]" }
9 | ,trimListValues : true
10 | };
11 |
12 | /** Parse a string into a list on the given delimiter character,
13 | respecting embedded quotes and brackets
14 | */
15 | selblocks.InfixExpressionParser.splitList= function splitList(str, delim)
16 | {
17 | var values = [];
18 | var prev = 0, cur = 0;
19 | while (cur < str.length) {
20 | if (str.charAt(cur) != delim) {
21 | cur = this.spanSub(str, cur);
22 | if (cur == -1)
23 | throw new Error("Unbalanced expression grouping at: " + str.substr(prev));
24 | }
25 | else {
26 | var value = str.substring(prev, cur);
27 | if (this.trimListValues)
28 | value = value.trim();
29 | values.push(value);
30 | prev = cur + 1;
31 | }
32 | cur++;
33 | }
34 | values.push(str.substring(prev));
35 | if (values.length == 1 && values[0].trim() == "") {
36 | values.length = 0;
37 | }
38 | return values;
39 | };
40 |
41 | /** Scan to the given chr, skipping over intervening matching brackets
42 | */
43 | selblocks.InfixExpressionParser.spanTo= function spanTo(str, i, chr)
44 | {
45 | while (str.charAt(i) != chr) {
46 | i = this.spanSub(str, i);
47 | if (i == -1 || i >= str.length)
48 | return -1;
49 | i++;
50 | }
51 | return i;
52 | }
53 |
54 | /** If character at the given index is a open/quote character, then scan to its matching close/quote
55 | */
56 | selblocks.InfixExpressionParser.spanSub= function spanSub(str, i)
57 | {
58 | if (i < str.length) {
59 | if (str.charAt(i) == "(") return this.spanTo(str, i+1, ")"); // recursively skip over intervening matching brackets
60 | else if (str.charAt(i) == "[") return this.spanTo(str, i+1, "]");
61 | else if (str.charAt(i) == "{") return this.spanTo(str, i+1, "}");
62 | else if (str.charAt(i) == "'") return str.indexOf("'", i+1); // no special meaning for intervening brackets
63 | else if (str.charAt(i) == '"') return str.indexOf('"', i+1);
64 | }
65 | return i;
66 | };
67 |
68 | /** Format the given values array into a delimited list string
69 | An optional transformFunc operates on each value.
70 | */
71 | selblocks.InfixExpressionParser.formatList= function formatList(delim, values, left, transformFunc, right)
72 | {
73 | var buf = "";
74 | for (var i = 0; i < values.length; i++) {
75 | var value = ((transformFunc) ? transformFunc(values[i], i) : values[i]);
76 | if (buf) buf += delim || " ";
77 | if (left) buf += left;
78 | if (value) buf += value;
79 | if (right) buf += right;
80 | }
81 | return buf;
82 | };
83 |
--------------------------------------------------------------------------------
/sel-blocksTests/try05 - catch specific error, then finally.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try05
9 |
10 |
11 |
12 |
13 | try05
14 |
15 |
16 | log
17 | "-- catch specific error, then finally --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | t-spec-outer
39 |
40 |
41 |
42 | emit
43 | "trying outer"
44 |
45 |
46 |
47 | assertEval
48 | selblocks.tcf.nestingLevel
49 | -1
50 |
51 |
52 | emit
53 | "([/"
54 |
55 |
56 |
57 |
58 | try
59 | t-spec-inner
60 |
61 |
62 |
63 | emit
64 | "trying inner"
65 |
66 |
67 |
68 | throw
69 | "blamo inner"
70 |
71 |
72 |
73 | assertEval
74 | "this command should not be reached, due to throw"
75 |
76 |
77 |
78 | catch
79 | /blamo inner/
80 |
81 |
82 |
83 | emit
84 | "caught '" + _error.message + "'"
85 |
86 |
87 |
88 | finally
89 |
90 |
91 |
92 |
93 | emit
94 | "finally"
95 |
96 |
97 |
98 | endTry
99 | t-spec-inner
100 |
101 |
102 |
103 |
104 | assertEval
105 | selblocks.tcf.nestingLevel
106 | -1
107 |
108 |
109 | emit
110 | "/])"
111 |
112 |
113 |
114 | endTry
115 | t-spec-outer
116 |
117 |
118 |
119 |
120 | assertEval
121 | selblocks.tcf.nestingLevel
122 | -1
123 |
124 |
125 | emit
126 | "/])"
127 |
128 |
129 |
130 | assertEmitted
131 | "([/~trying outer~([/~trying inner~caught 'blamo inner'~finally~/])~/])"
132 |
133 |
134 |
135 |
136 |
137 |
--------------------------------------------------------------------------------
/sel-blocksTests/try08 - bubble up to catch ALL via finally.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try08
9 |
10 |
11 |
12 |
13 | try08
14 |
15 |
16 | log
17 | "-- bubble up to catch ALL via finally --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | t-allfin-outer
39 |
40 |
41 |
42 | emit
43 | "trying-outer"
44 |
45 |
46 |
47 | assertEval
48 | selblocks.tcf.nestingLevel
49 | 0
50 |
51 |
52 |
53 | try
54 | t-allfin-inner
55 |
56 |
57 |
58 | emit
59 | "trying"
60 |
61 |
62 |
63 | throw
64 | "blamo try-catch-finally"
65 |
66 |
67 |
68 | assertEval
69 | "this command should not be reached, due to throw"
70 |
71 |
72 |
73 | catch
74 | /will NOT catch it/
75 |
76 |
77 |
78 | emit
79 | "caught '" + _error.message + "'"
80 |
81 |
82 |
83 | finally
84 |
85 |
86 |
87 |
88 | emit
89 | "finally"
90 |
91 |
92 |
93 | endTry
94 | t-allfin-inner
95 |
96 |
97 |
98 |
99 | assertEval
100 | selblocks.tcf.nestingLevel
101 | 0
102 |
103 |
104 | catch
105 |
106 |
107 |
108 |
109 | emit
110 | "caught-outer '" + _error.message + "'"
111 |
112 |
113 |
114 | endTry
115 | t-allfin-outer
116 |
117 |
118 |
119 |
120 | assertEval
121 | selblocks.tcf.nestingLevel
122 | -1
123 |
124 |
125 | emit
126 | "/])"
127 |
128 |
129 |
130 | assertEmitted
131 | "([/~trying-outer~trying~finally~caught-outer 'blamo try-catch-finally'~/])"
132 |
133 |
134 |
135 |
136 |
137 |
--------------------------------------------------------------------------------
/sel-blocksTests/if01.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | if02
8 |
9 |
10 |
11 |
12 | if02
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | emit
21 | "BEFORE"
22 |
23 |
24 |
25 |
26 | if
27 | true
28 |
29 |
30 |
31 | emit
32 | "truthy"
33 |
34 |
35 |
36 | endIf
37 |
38 |
39 |
40 |
41 |
42 | if
43 | false
44 |
45 |
46 |
47 | emit
48 | "falsey"
49 |
50 |
51 |
52 | endIf
53 |
54 |
55 |
56 |
57 |
58 | if
59 | true
60 |
61 |
62 |
63 | emit
64 | "A"
65 |
66 |
67 |
68 | else
69 |
70 |
71 |
72 |
73 | emit
74 | "B"
75 |
76 |
77 |
78 | endIf
79 |
80 |
81 |
82 |
83 |
84 | if
85 | false
86 |
87 |
88 |
89 | emit
90 | "X"
91 |
92 |
93 |
94 | else
95 |
96 |
97 |
98 |
99 | emit
100 | "Y"
101 |
102 |
103 |
104 | endIf
105 |
106 |
107 |
108 |
109 |
110 | if
111 | false
112 |
113 |
114 |
115 | emit
116 | "false teeth"
117 |
118 |
119 |
120 | else
121 |
122 |
123 |
124 |
125 | if
126 | true
127 |
128 |
129 |
130 | emit
131 | "truthF"
132 |
133 |
134 |
135 | else
136 |
137 |
138 |
139 |
140 | emit
141 | "false false"
142 |
143 |
144 |
145 | endIf
146 |
147 |
148 |
149 |
150 | endIf
151 |
152 |
153 |
154 |
155 |
156 | emit
157 | "AFTER"
158 |
159 |
160 |
161 |
162 | assertEmitted
163 | "BEFORE~truthy~A~Y~truthF~AFTER"
164 |
165 |
166 |
167 |
168 |
169 |
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/content/extensions/selenium-executionloop-handleAsTryBlock.js:
--------------------------------------------------------------------------------
1 | /* Copyright 2011 Chris Noe
2 | * Copyright 2015, 2016 Peter Kehl
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 1.1. If a copy of the MPL was not distributed with this file,
5 | * You can obtain one at http://mozilla.org/MPL/1.1/.
6 | */
7 | "use strict";
8 |
9 | // Following assignments is purely for JSDoc.
10 | /** @namespace */
11 | selblocks= selblocks;
12 |
13 | // Based on a part of $$.handleAsTryBlock from SelBlocks
14 | selblocks.testLoopResumeHandleFailedResult= function testLoopResumeHandleFailedResult() {
15 | // Selenium IDE doesn't stop running on verifications. Therefore verifications shouldn't trigger 'catch' clause. Hence we do suppress making the test case marked as failed, and we log at info level only.
16 | LOG.info( "try..catch..endTry suppressed verification failure from command: " + this.currentCommand.command + " | " + this.currentCommand.target + " | " + this.currentCommand.value + " |");
17 | this.result.failed= false;
18 | this.result.passed= true;
19 | };
20 |
21 | // Based on a part of $$.handleAsTryBlock from SelBlocks
22 | selblocks.testLoopResumeHandleError= function testLoopResumeHandleError( e ) {
23 | LOG.debug( 'testLoopResumeHandleError');
24 | var originalMessage= e.message; // Selenium IDE generates 'false' message for failed assertions, and those then would only match catch | 'false' |. Following makes them catchable by the actual assertion message.
25 | if( e.message==='false' ) {
26 | e.message= this.currentCommand.command + " | " + this.currentCommand.target + " | " + this.currentCommand.value + " |";
27 | }
28 | if( /*isManaged*/selblocks.fn.getInterceptTop() && selblocks.fn.getInterceptTop().attrs.manageError(e) ) {
29 | var message= originalMessage!=='false'
30 | ? '. The message: ' +originalMessage
31 | : '';
32 | LOG.debug( 'try..catch..endTry caught an exception or assert failure from command: ' + this.currentCommand.command + " | " + this.currentCommand.target + " | " + this.currentCommand.value + " |" +message );
33 | this.continueTest();
34 | }
35 | else if( selenium.callStack().top().invokedFromJavascript ) {
36 | LOG.debug( 'testLoopResumeHandleError: invokedFromJavascript, popping callStack');
37 | !selenium.callStack().top().frameFromAsync || !selenium.callStack().top().onFailure || window.setTimeout( ()=>selenium.callStack().top().onFailure( e ), 0 );
38 | LOG.debug( 'testLoopResumeHandleError: invokedFromJavascript, after calling onFailure (if any and if applicable)');
39 | selenium.callStack().pop();
40 | this.continueTest();
41 | }
42 | else {
43 | this._handleCommandError(e); // causes command to be marked in red
44 | if( 'seLiteVerification' in e ) {
45 | this.continueTest();
46 | }
47 | else {
48 | this.testComplete();
49 | }
50 | }
51 | };
52 |
53 | // Classic SelBlocks had handleAsTryBlock() here, but SelBlocks Global uses testLoopResumeHandleFailedResult() and testLoopResumeHandleError() instead. See editor.testLoopResume() in SeLite TestCase Debug Context.
54 |
--------------------------------------------------------------------------------
/selenese-scripts/various/promised_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | promised_case
8 |
9 |
10 |
11 |
12 | promised_case
13 |
14 |
15 | getPromised
16 | Promise.resolve(1)
17 |
18 |
19 |
20 | storePromised
21 | Promise.resolve(1)
22 | one
23 |
24 |
25 | assertEval
26 | $one
27 | 1
28 |
29 |
30 |
31 |
32 | verifyPromised
33 | Promise.resolve(1)
34 | regexp:1
35 |
36 |
37 | verifyNotPromised
38 | Promise.resolve(1)
39 | 2
40 |
41 |
42 | assertPromised
43 | Promise.resolve(1)
44 | 1
45 |
46 |
47 | assertNotPromised
48 | Promise.resolve(1)
49 | glob:two
50 |
51 |
52 |
53 |
54 | function
55 | verifyPromisedFail
56 |
57 |
58 |
59 | verifyPromised
60 | Promise.resolve(2)
61 | regexp:1
62 |
63 |
64 | endFunction
65 |
66 |
67 |
68 |
69 | call
70 | assertFunctionFailure
71 | func='verifyPromisedFail'
72 |
73 |
74 |
75 | function
76 | verifyNotPromisedFail
77 |
78 |
79 |
80 | verifyNotPromised
81 | Promise.resolve(2)
82 | glob:2
83 |
84 |
85 | endFunction
86 |
87 |
88 |
89 |
90 | call
91 | assertFunctionFailure
92 | func='verifyNotPromisedFail'
93 |
94 |
95 |
96 | function
97 | assertPromisedFail
98 |
99 |
100 |
101 | assertPromised
102 | Promise.resolve(2)
103 | 3
104 |
105 |
106 | endFunction
107 |
108 |
109 |
110 |
111 | call
112 | assertFunctionFailure
113 | func='assertPromisedFail'
114 |
115 |
116 |
117 | function
118 | assertNotPromisedFail
119 |
120 |
121 |
122 | assertNotPromised
123 | Promise.resolve(2)
124 | glob:2
125 |
126 |
127 | endFunction
128 |
129 |
130 |
131 |
132 | call
133 | assertFunctionFailure
134 | func='assertNotPromisedFail'
135 |
136 |
137 |
138 |
139 |
--------------------------------------------------------------------------------
/sel-blocksTests/try11 - bubble up to catch specific error via finally.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try11
9 |
10 |
11 |
12 |
13 | try11
14 |
15 |
16 | log
17 | "-- bubble up to catch specific error via finally --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | bub-spec-outer
39 |
40 |
41 |
42 | emit
43 | "trying outer"
44 |
45 |
46 |
47 | assertEval
48 | selblocks.tcf.nestingLevel
49 | 0
50 |
51 |
52 |
53 | try
54 | bub-spec-inner
55 |
56 |
57 |
58 | emit
59 | "trying inner"
60 |
61 |
62 |
63 | assertEval
64 | selblocks.tcf.nestingLevel
65 | 1
66 |
67 |
68 | emit
69 | "throwing inner"
70 |
71 |
72 |
73 | throw
74 | "blamo"
75 |
76 |
77 |
78 | assertEval
79 | "this command should not be reached, due to throw"
80 |
81 |
82 |
83 | finally
84 |
85 |
86 |
87 |
88 | emit
89 | "finally"
90 |
91 |
92 |
93 | endTry
94 | bub-spec-inner
95 |
96 |
97 |
98 |
99 | catch
100 | /blamo/
101 |
102 |
103 |
104 | emit
105 | "caught '" + _error.message + "'"
106 |
107 |
108 |
109 | finally
110 |
111 |
112 |
113 |
114 | emit
115 | "finally"
116 |
117 |
118 |
119 | endTry
120 | bub-spec-outer
121 |
122 |
123 |
124 |
125 | assertEval
126 | selblocks.tcf.nestingLevel
127 | -1
128 |
129 |
130 | emit
131 | "/])"
132 |
133 |
134 |
135 | assertEmitted
136 | "([/~trying outer~trying inner~throwing inner~finally~caught 'blamo'~finally~/])"
137 |
138 |
139 |
140 |
141 |
142 |
--------------------------------------------------------------------------------
/sel-blocksTests/try12 - throw, catch, rethrow.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try12
9 |
10 |
11 |
12 |
13 | try12
14 |
15 |
16 | log
17 | "-- throw, catch, rethrow --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | outer
39 |
40 |
41 |
42 | emit
43 | "trying outer"
44 |
45 |
46 |
47 | assertEval
48 | selblocks.tcf.nestingLevel
49 | 0
50 |
51 |
52 |
53 | try
54 | inner
55 |
56 |
57 |
58 | emit
59 | "trying inner"
60 |
61 |
62 |
63 | assertEval
64 | selblocks.tcf.nestingLevel
65 | 1
66 |
67 |
68 | emit
69 | "throwing blamo1"
70 |
71 |
72 |
73 | throw
74 | "blamo1"
75 |
76 |
77 |
78 | assertEval
79 | "this command should not be reached, due to throw"
80 |
81 |
82 |
83 | catch
84 | /blamo1/
85 |
86 |
87 |
88 | emit
89 | "caught '" + _error.message + "'"
90 |
91 |
92 |
93 | emit
94 | "throwing blamo2"
95 |
96 |
97 |
98 | throw
99 | "blamo2"
100 |
101 |
102 |
103 | endTry
104 | inner
105 |
106 |
107 |
108 |
109 | catch
110 | /blamo2/
111 |
112 |
113 |
114 | emit
115 | "caught '" + _error.message + "'"
116 |
117 |
118 |
119 | endTry
120 | outer
121 |
122 |
123 |
124 |
125 | assertEval
126 | selblocks.tcf.nestingLevel
127 | -1
128 |
129 |
130 | emit
131 | "/])"
132 |
133 |
134 |
135 | assertEmitted
136 | "([/~trying outer~trying inner~throwing blamo1~caught 'blamo1'~throwing blamo2~caught 'blamo2'~/])"
137 |
138 |
139 |
140 |
141 |
142 |
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/content/about.xul:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | Commands:
36 |
37 | if, else, elseIf
38 | try, catch, finally, throw
39 | for, foreach, while, continue, break
40 | call, function, return
41 | loadJsonVars, loadXmlVars, forJson, forXml
42 | exitTest
43 |
44 |
45 |
46 | Function and loop parameters create regular Selenium variables that are local to a block,
47 | overriding variables of the same name, and that are restored when the block exits.
48 |
49 |
50 | Selenium variables can be set via external JSON/XML data file(s).
51 |
52 |
53 | Command parameters are Javascript expressions that are evaluated with Selenium variables in scope,
54 | which can therefore be referenced by their simple names, e.g.: i+1
55 |
56 |
57 | A function definition can appear anywhere; they are skipped in normal execution flow.
58 |
59 |
60 | Functions can be invoked recursively.
61 |
62 |
63 |
64 |
65 |
66 |
67 | See:
68 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/content/extensions/function-intercepting.js:
--------------------------------------------------------------------------------
1 | /* Copyright 2011 Chris Noe
2 | * Copyright 2015, 2016 Peter Kehl
3 | * This Source Code Form is subject to the terms of the Mozilla Public
4 | * License, v. 1.1. If a copy of the MPL was not distributed with this file,
5 | * You can obtain one at http://mozilla.org/MPL/1.1/.
6 | */
7 | "use strict";
8 |
9 | // Following assignments is purely for JSDoc.
10 | /** @namespace selblocks*/
11 | selblocks= selblocks;
12 |
13 | // name-space for function interception
14 | /** @namespace
15 | */
16 | selblocks.fn = {};
17 |
18 | //@TODO It looks like functions intercepted by the following can't have any parameters. -Peter Kehl
19 | /** execute the given function before each call of the specified function
20 | */
21 | selblocks.fn.interceptBefore = function interceptBefore(targetObj, targetFnName, _fn) {
22 | var existing_fn = targetObj[targetFnName];
23 | targetObj[targetFnName] = function() {
24 | _fn.call(this);
25 | return existing_fn.call(this);
26 | };
27 | };
28 | /** execute the given function after each call of the specified function
29 | */
30 | selblocks.fn.interceptAfter = function interceptAfter(targetObj, targetFnName, _fnAfter) {
31 | var existing_fn = targetObj[targetFnName];
32 | targetObj[targetFnName] = function() {
33 | existing_fn.call(this);
34 | _fnAfter.call(this);
35 | };
36 | };
37 | /** replace the specified function with the given function
38 | @member {function}
39 | */
40 | selblocks.fn.interceptReplace = function interceptReplace(targetObj, targetFnName, _fn) {
41 | targetObj[targetFnName] = function() {
42 | //var existing_fn = targetObj[targetFnName] = _fn;
43 | return _fn.call(this);
44 | };
45 | };
46 |
47 | /** @member {Array} */
48 | selblocks.fn.interceptStack = [];
49 |
50 | /** replace the specified function, saving the original function on a stack
51 | @member {function}
52 | */
53 | selblocks.fn.interceptPush = function interceptPush(targetObj, targetFnName, _fnTemp, frameAttrs) {
54 | // selblocks.LOG.warn("interceptPush " + (frameAttrs ? frameAttrs : ""));
55 | var frame = {
56 | targetObj: targetObj
57 | ,targetFnName: targetFnName
58 | ,savedFn: targetObj[targetFnName]
59 | ,attrs: frameAttrs
60 | };
61 | selblocks.fn.interceptStack.push(frame);
62 | targetObj[targetFnName] = _fnTemp;
63 | };
64 |
65 | /** restore the most recent function replacement
66 | @member {function}
67 | */
68 | selblocks.fn.interceptPop = function interceptPop() {
69 | var frame = selblocks.fn.interceptStack.pop();
70 | // selblocks.LOG.warn("interceptPop " + (frame.attrs ? frame.attrs : ""));
71 | frame.targetObj[frame.targetFnName] = frame.savedFn;
72 | };
73 |
74 | /** @member {function} */
75 | selblocks.fn.getInterceptTop = function getInterceptTop() {
76 | return selblocks.fn.interceptStack[selblocks.fn.interceptStack.length-1];
77 | };
78 |
79 | /** replace the specified function, but then restore the original function as soon as it is call
80 | @member {function}
81 | */
82 | selblocks.fn.interceptOnce = function interceptOnce(targetObj, targetFnName, _fn) {
83 | selblocks.fn.interceptPush(targetObj, targetFnName, function(){
84 | selblocks.fn.interceptPop(); // un-intercept
85 | var args = Array.prototype.slice.call(arguments);
86 | _fn.apply(this, args); });
87 | };
88 |
--------------------------------------------------------------------------------
/sel-blocksTests/try06 - catch-throw, finally-throw.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try06
9 |
10 |
11 |
12 |
13 | try06
14 |
15 |
16 | log
17 | "-- catch/throw, finally/throw --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | tcf-trap
39 |
40 |
41 |
42 |
43 | assertEval
44 | selblocks.tcf.nestingLevel
45 | 0
46 |
47 |
48 | try
49 | tcf
50 |
51 |
52 |
53 | emit
54 | "trying"
55 |
56 |
57 |
58 | emit
59 | "throwing A"
60 |
61 |
62 |
63 | throw
64 | "blamoA"
65 |
66 |
67 |
68 | assertEval
69 | "this command should not be reached, due to thrown"
70 |
71 |
72 |
73 | catch
74 | /blamoA/
75 |
76 |
77 |
78 | emit
79 | "caught '" + _error.message + "'"
80 |
81 |
82 |
83 | emit
84 | "throwing B"
85 |
86 |
87 |
88 | throw
89 | "blamoB"
90 |
91 |
92 |
93 | finally
94 |
95 |
96 |
97 |
98 | emit
99 | "finally"
100 |
101 |
102 |
103 | emit
104 | "throwing C"
105 |
106 |
107 |
108 | throw
109 | "blamoC"
110 |
111 |
112 |
113 | endTry
114 |
115 |
116 |
117 |
118 |
119 | assertEval
120 | selblocks.tcf.nestingLevel
121 | 0
122 |
123 |
124 | catch
125 |
126 |
127 |
128 |
129 | emit
130 | "caught '" + _error.message + "'"
131 |
132 |
133 |
134 | endTry
135 |
136 |
137 |
138 |
139 |
140 | assertEval
141 | selblocks.tcf.nestingLevel
142 | -1
143 |
144 |
145 | emit
146 | "/])"
147 |
148 |
149 |
150 | assertEmitted
151 | "([/~trying~throwing A~caught 'blamoA'~throwing B~finally~throwing C~caught 'blamoC'~/])"
152 |
153 |
154 |
155 |
156 |
157 |
--------------------------------------------------------------------------------
/sel-blocksTests/try20 - command bubbling, return replaced by error.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try20
9 |
10 |
11 |
12 |
13 | try20
14 |
15 |
16 | log
17 | "-- command bubbling, return replaced by error --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | emit
32 | "calling"
33 |
34 |
35 |
36 | call
37 | cmdBubC
38 |
39 |
40 |
41 | emit
42 | "returned ${_result}"
43 |
44 |
45 |
46 | function
47 | cmdBubC
48 |
49 |
50 |
51 | emit
52 | "in cmdBubC"
53 |
54 |
55 |
56 | assertEval
57 | selblocks.tcf.nestingLevel
58 | -1
59 |
60 |
61 |
62 | try
63 | cmdBub-tcf-guardrail
64 |
65 |
66 |
67 | assertEval
68 | selblocks.tcf.nestingLevel
69 | 0
70 |
71 |
72 |
73 | try
74 | cmdBub-tcf
75 |
76 |
77 |
78 | emit
79 | "trying"
80 |
81 |
82 |
83 | emit
84 | "returning (1)"
85 |
86 |
87 |
88 | return
89 | 1
90 |
91 |
92 |
93 | finally
94 |
95 |
96 |
97 |
98 | emit
99 | "finallying"
100 |
101 |
102 |
103 | emit
104 | "throwing"
105 |
106 |
107 |
108 | throw
109 | "this-error-replaces-return-1"
110 |
111 |
112 |
113 | endTry
114 |
115 |
116 |
117 |
118 |
119 | catch
120 | /this-error-replaces-return-1/
121 |
122 |
123 |
124 | emit
125 | "caught '" + _error.message + "'"
126 |
127 |
128 |
129 | assertEval
130 | selblocks.tcf.nestingLevel
131 | 0
132 |
133 |
134 | endTry
135 |
136 |
137 |
138 |
139 |
140 | endFunction
141 |
142 |
143 |
144 |
145 | emit
146 | "/])"
147 |
148 |
149 |
150 | assertEmitted
151 | "([/~calling~in cmdBubC~trying~returning (1)~finallying~throwing~caught 'this-error-replaces-return-1'~returned 2~/])"
152 |
153 |
154 |
155 |
156 |
157 |
--------------------------------------------------------------------------------
/sel-blocksTests/if02.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | if02
8 |
9 |
10 |
11 |
12 | if02
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 |
21 | if
22 | true
23 |
24 |
25 |
26 | emit
27 | "if-y"
28 |
29 |
30 |
31 | elseIf
32 | true
33 |
34 |
35 |
36 | emit
37 | "elseIf-y"
38 |
39 |
40 |
41 | endIf
42 |
43 |
44 |
45 |
46 |
47 | if
48 | false
49 |
50 |
51 |
52 | emit
53 | "if-y"
54 |
55 |
56 |
57 | elseIf
58 | true
59 |
60 |
61 |
62 | emit
63 | "elseIf-y"
64 |
65 |
66 |
67 | endIf
68 |
69 |
70 |
71 |
72 |
73 | if
74 | false
75 |
76 |
77 |
78 | emit
79 | "if-y"
80 |
81 |
82 |
83 | elseIf
84 | true
85 |
86 |
87 |
88 | emit
89 | "elseIf-a1y"
90 |
91 |
92 |
93 | elseIf
94 | true
95 |
96 |
97 |
98 | emit
99 | "else-a2y"
100 |
101 |
102 |
103 | endIf
104 |
105 |
106 |
107 |
108 |
109 | if
110 | false
111 |
112 |
113 |
114 | emit
115 | "if-y"
116 |
117 |
118 |
119 | elseIf
120 | false
121 |
122 |
123 |
124 | emit
125 | "elseIf-b1y"
126 |
127 |
128 |
129 | elseIf
130 | true
131 |
132 |
133 |
134 | emit
135 | "elseIf-b2y"
136 |
137 |
138 |
139 | endIf
140 |
141 |
142 |
143 |
144 |
145 | if
146 | false
147 |
148 |
149 |
150 | emit
151 | "if-y"
152 |
153 |
154 |
155 | elseIf
156 | false
157 |
158 |
159 |
160 | emit
161 | "elseIf-y"
162 |
163 |
164 |
165 | else
166 |
167 |
168 |
169 |
170 | emit
171 | "else-y"
172 |
173 |
174 |
175 | endIf
176 |
177 |
178 |
179 |
180 | assertEmitted
181 | "if-y~elseIf-y~elseIf-a1y~elseIf-b2y~else-y"
182 |
183 |
184 |
185 |
186 |
187 |
--------------------------------------------------------------------------------
/sel-blocksTests/function03-recursive.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | function03-recursive
8 |
9 |
10 |
11 |
12 | function03-recursive
13 |
14 |
15 | resetEmitted
16 |
17 |
18 |
19 |
20 | deleteVars
21 | degree, n, _result, ud
22 |
23 |
24 |
25 | store
26 | 7
27 | degree
28 |
29 |
30 | startTimer
31 |
32 | factorial ${degree}
33 |
34 |
35 | call
36 | fac
37 | n=degree
38 |
39 |
40 | timerElapsed
41 |
42 |
43 |
44 |
45 | emit
46 | degree + "!=" + _result
47 |
48 |
49 |
50 |
51 |
52 | function
53 | fac
54 | n
55 |
56 |
57 | if
58 | n <= 1
59 |
60 |
61 |
62 | return
63 | 1
64 |
65 |
66 |
67 | else
68 |
69 |
70 |
71 |
72 | call
73 | fac
74 | n = n-1
75 |
76 |
77 | emit
78 | _result
79 |
80 |
81 |
82 | return
83 | n * _result
84 |
85 |
86 |
87 | endIf
88 |
89 |
90 |
91 |
92 | endFunction
93 |
94 |
95 |
96 |
97 |
98 |
99 | function
100 | uno
101 |
102 |
103 |
104 | emit
105 | "UNO"
106 |
107 |
108 |
109 | storeEval
110 | ${ud}-1
111 | ud
112 |
113 |
114 | if
115 | ud > 0
116 |
117 |
118 |
119 | call
120 | due
121 |
122 |
123 |
124 | endIf
125 |
126 |
127 |
128 |
129 | endFunction
130 | uno
131 |
132 |
133 |
134 |
135 | function
136 | due
137 |
138 |
139 |
140 | emit
141 | "DUE"
142 |
143 |
144 |
145 | storeEval
146 | ${ud}-1
147 | ud
148 |
149 |
150 | if
151 | ud > 0
152 |
153 |
154 |
155 | call
156 | uno
157 |
158 |
159 |
160 | endIf
161 |
162 |
163 |
164 |
165 | endFunction
166 | due
167 |
168 |
169 |
170 |
171 | store
172 | 5
173 | ud
174 |
175 |
176 | call
177 | uno
178 |
179 |
180 |
181 |
182 | assertEmitted
183 | "1~2~6~24~120~720~7!=5040~UNO~DUE~UNO~DUE~UNO"
184 |
185 |
186 |
187 |
188 |
189 |
--------------------------------------------------------------------------------
/sel-blocksTests/try13 - bubble out of nested function calls.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | try13
9 |
10 |
11 |
12 |
13 | try13
14 |
15 |
16 | log
17 | "-- bubble out of nested function calls --"
18 |
19 |
20 |
21 | resetEmitted
22 |
23 |
24 |
25 |
26 | emit
27 | "([/"
28 |
29 |
30 |
31 | assertEval
32 | selblocks.tcf.nestingLevel
33 | -1
34 |
35 |
36 |
37 | try
38 | bub-invoke
39 |
40 |
41 |
42 | emit
43 | "trying"
44 |
45 |
46 |
47 | emit
48 | "calling"
49 |
50 |
51 |
52 | call
53 | subBub
54 | n = 0
55 |
56 |
57 | assertEval
58 | "this command should not be reached, due error thrown in function"
59 |
60 |
61 |
62 | catch
63 | /blamo/
64 |
65 |
66 |
67 | emit
68 | "caught '" + _error.message + "'"
69 |
70 |
71 |
72 | finally
73 |
74 |
75 |
76 |
77 | emit
78 | "finally"
79 |
80 |
81 |
82 | endTry
83 | bub-invoke
84 |
85 |
86 |
87 | assertEval
88 | selblocks.tcf.nestingLevel
89 | -1
90 |
91 |
92 |
93 | function
94 | subBub
95 |
96 |
97 |
98 |
99 | try
100 | tcf-inner
101 |
102 |
103 |
104 | emit
105 | "${n}) trying-inner"
106 |
107 |
108 |
109 | if
110 | n < 2
111 |
112 |
113 |
114 | emit
115 | "${n}) calling"
116 |
117 |
118 |
119 | call
120 | subBub
121 | n = n+1
122 |
123 |
124 | else
125 |
126 |
127 |
128 |
129 | emit
130 | "${n}) throwing"
131 |
132 |
133 |
134 | throw
135 | "blamo"
136 |
137 |
138 |
139 | endIf
140 |
141 |
142 |
143 |
144 | finally
145 |
146 |
147 |
148 |
149 | emit
150 | "${n}) finally"
151 |
152 |
153 |
154 | endTry
155 | tcf-inner
156 |
157 |
158 |
159 |
160 | assertEval
161 | selblocks.tcf.nestingLevel
162 | 0
163 |
164 |
165 | endFunction
166 |
167 |
168 |
169 |
170 | emit
171 | "/])"
172 |
173 |
174 |
175 | assertEmitted
176 | "([/~trying~calling~0) trying-inner~0) calling~1) trying-inner~1) calling~2) trying-inner~2) throwing~2) finally~1) finally~0) finally~caught 'blamo'~finally~/])"
177 |
178 |
179 |
180 |
181 |
182 |
--------------------------------------------------------------------------------
/selenese-scripts/various/ifPromise_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | ifPromise_case
8 |
9 |
10 |
11 |
12 | ifPromise_case
13 |
14 |
15 | storePromised
16 | new Promise( (resolve)=>{ resolve(true); } )
17 | resolvedTrue
18 |
19 |
20 | assertEval
21 | ${resolvedTrue}
22 | true
23 |
24 |
25 | storePromised
26 | new Promise( (resolve)=>{ resolve(false); } )
27 | resolvedFalse
28 |
29 |
30 | assertEval
31 | ${resolvedFalse}
32 | false
33 |
34 |
35 | storePromised
36 | new Promise( (resolve)=>{ resolve(undefined); } )
37 | undefined
38 |
39 |
40 | storePromised
41 | new Promise( (resolve)=>{ resolve(null); } )
42 | null
43 |
44 |
45 |
46 | storeEval
47 | Math.min(150, selenium.defaultTimeout-150)
48 | shortPause
49 |
50 |
51 | ifPromise
52 | new Promise( (resolve, reject)=>{ window.setTimeout( ()=>resolve(1), ${shortPause} ); } )
53 |
54 |
55 |
56 | log
57 | promise equaled true
58 | warn
59 |
60 |
61 | endIfPromise
62 |
63 |
64 |
65 |
66 |
67 |
68 | getEval
69 | selenium.defaultTimeout= 150;
70 |
71 |
72 |
73 | if
74 | false
75 |
76 |
77 |
78 |
79 |
80 | getEval
81 | var nowMilliSec=Date.now(); while( Date.now()-nowMilliSec<selenium.defaultTimeout+100 ); LOG.info('getEval finished while() loop, even though it was overtime.');
82 |
83 |
84 |
85 | promise
86 | new Promise( ()=>'never' )
87 |
88 |
89 |
90 | endIf
91 |
92 |
93 |
94 |
95 |
96 |
97 | getEval
98 | $promiseTimedOut= undefined
99 |
100 |
101 |
102 | try
103 |
104 |
105 |
106 |
107 | storePromised
108 | new Promise( ()=>{} )
109 | never
110 |
111 |
112 | catch
113 |
114 |
115 |
116 |
117 | storeEval
118 | true
119 | promiseTimedOut
120 |
121 |
122 | endTry
123 |
124 |
125 |
126 |
127 | getEval
128 | $promiseTimedOut= undefined
129 |
130 |
131 |
132 |
133 | try
134 |
135 |
136 |
137 |
138 | promise
139 | new Promise( resolve => window.setTimeout( ()=>resolve(1), selenium.defaultTimeout+100) )
140 |
141 |
142 |
143 | catch
144 |
145 |
146 |
147 |
148 | storeEval
149 | true
150 | promiseTimedOut
151 |
152 |
153 | endTry
154 |
155 |
156 |
157 |
158 |
159 | getEval
160 | if( !$promiseTimedOut) { throw new Error( "XXX _case: A promise should have timed out." ); }
161 |
162 |
163 |
164 |
165 |
166 |
--------------------------------------------------------------------------------
/notes/design-notes.txt:
--------------------------------------------------------------------------------
1 | Command Categories
2 |
3 | branching
4 | skipNext : skip over some commands
5 | goto : jump to target label
6 | if x2 : skip around if-block, or into else-block
7 | cascadeElseIf() X3 : skip around else and/or elseIf blocks
8 | enterLoop() : jump out of loop if complete
9 | iterateLoop() : jump back to top of loop if not complete
10 | continue : jump back to top of loop
11 | break : jump out of loop
12 | call : jump into function body
13 | function : skip around function body
14 | returnFromFunction() : jump back to call command
15 | catch x2 : skip around unused cach-block, into finally-block or out of tcf
16 | handleCommandError() x2 : jump into catch-block or finally-block
17 |
18 | execute enclosing finally-blocks during command bubbling:
19 | continue/break (loop)
20 | return (call)
21 | exitTest
22 |
23 | jump in-to/out-of restrictions
24 | goto/skipNext
25 | to/from:
26 | loop
27 | function
28 | try/catch/finally
29 |
30 | ======================================================================
31 |
32 | Name Space and Major Functions
33 |
34 | selblocks ($$) object
35 | .LOG
36 | .unwrapObject()
37 | .InfixExpressionParser()
38 | .handleAsExitTest()
39 | .tcf
40 | .nestingLevel
41 | .bubbling
42 | .mode (error/command)
43 | .error
44 | .srcIdx
45 | ._isStopCriteria
46 | .fn
47 | .fnStack[]
48 | .interceptBefore()
49 | .interceptAfter()
50 | .interceptReplace()
51 | .interceptPush()
52 | .interceptPop()
53 | .getInterceptAttrs()
54 | .interceptOnce()
55 | .xp
56 | .evaluateXpath()
57 | .foreachNode()
58 | .logXpathEval()
59 | .selectElements()
60 | .selectNodes()
61 | .selectNodeSnapshot()
62 |
63 | ======================================================================
64 |
65 | Object Structures for Block Controls
66 |
67 | blockDefs : static block structures
68 | cmdName
69 | idx (command line)
70 | nature (if/try/loop/function)
71 | [if] ifIdx, elseIfIdxs, elseIdx, endIdx
72 | [try] name, tryIdx, catchIdx, finallyIdx, endIdx
73 | [loop] beginIdx, endIdx
74 | [function] funcIdx, endIdx
75 |
76 | callStack : call/return execution context
77 | name (of function)
78 | args
79 | savedArgs
80 | funcIdx
81 | returnIdx
82 | isReturning
83 | blockStack : block scope execution context
84 | [ifState]
85 | idx
86 | skipElseBlocks
87 | [loopState] (while/for/foreach/forJson/forXml)
88 | idx
89 | savedVars
90 | isComplete
91 | [tryState]
92 | idx
93 | execPhase
94 | hasCaught
95 | hasFinaled
96 |
97 | ======================================================================
98 |
99 | try/catch/finally
100 |
101 | At first glance, try/catch/finally seems to be a mechanism for handling errors. But errors are only one of several "bubbling" actions that '''try''' is intended to handle. Probably the best way to understand this is to consider what '''finally''' provides. It guarantees that the code inside the finally block will be executed after the code inside the try block, even if a bubbling event occurs in the try block. An error is one example of that, but there is also '''continue''', '''break''', and '''return''', each of which involves a kind of bubbling. For example, if you return from a function from inside of a try block, then the return will be delayed until the finally block can be executed.
102 |
103 | Both finally and catch are optional, but at least one of them must be present for try to mean anything.
104 |
105 | t r1 f r2
106 | t * c r0
107 | t * c r1 f r2
108 | t { t * f * c r1 | f r2
109 |
110 | ======================================================================
111 |
112 | As of SelBlocks 2, for loop variable(s) no longer need to be separately declared, (ie, listed in the Value field)
113 |
--------------------------------------------------------------------------------
/selenese-scripts/call-back/call_back_case.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | New Test
8 |
9 |
10 |
11 |
12 | New Test
13 |
14 |
15 |
16 | call
17 | assertReceivedParameters
18 | a=1, b=2
19 |
20 |
21 | call
22 | assertReceivedParameters
23 | =<>({ a: 1, b:2 })<>
24 |
25 |
26 |
27 |
28 | storeEval
29 | false
30 | seleneseCallFailed
31 |
32 |
33 | try
34 |
35 |
36 |
37 |
38 | call
39 | func
40 | unusedParameter=1@<>'Hi'<>
41 |
42 |
43 | catch
44 | /.*/
45 |
46 |
47 |
48 | storeEval
49 | true
50 | seleneseCallFailed
51 |
52 |
53 | finally
54 |
55 |
56 |
57 |
58 | assertEval
59 | storedVars.seleneseCallFailed
60 | true
61 |
62 |
63 | endTry
64 |
65 |
66 |
67 |
68 |
69 | call
70 | func
71 | =<>({ unusedParam: 'Hi' })<>
72 |
73 |
74 |
75 | storeEval
76 | false
77 | seleneseCallFailed
78 |
79 |
80 | try
81 |
82 |
83 |
84 |
85 | call
86 | func
87 | =<>({ shouldFail: true })<>
88 |
89 |
90 | catch
91 | /.*/
92 |
93 |
94 |
95 | storeEval
96 | true
97 | seleneseCallFailed
98 |
99 |
100 | finally
101 |
102 |
103 |
104 |
105 | assertEval
106 | storedVars.seleneseCallFailed
107 | true
108 |
109 |
110 | endTry
111 |
112 |
113 |
114 |
115 |
116 |
117 | call
118 | funcThatDoesntThrow
119 | shouldFail=true
120 |
121 |
122 |
123 | getEval
124 | selenium.callBackInFlow( 'func', '' )
125 |
126 |
127 |
128 |
129 | try
130 |
131 |
132 |
133 |
134 | getEval
135 | selenium.callBackInFlow( 'func', 'shouldFail="first failure"' )
136 |
137 |
138 |
139 | getEval
140 | alert( 'passed first failure' )
141 |
142 |
143 |
144 | catch
145 |
146 |
147 |
148 |
149 | getEval
150 | alert( 'caught first failure' )
151 |
152 |
153 |
154 | endTry
155 |
156 |
157 |
158 |
159 |
160 | call
161 | funcThatDoesntThrow
162 | shouldFail=true
163 |
164 |
165 |
166 | getEval
167 | setTimeout( ()=>{selenium.callBackOutFlow( 'func', 'shouldFail=true').then( ()=>alert('success from JS'), (exc)=>alert('failure from JS: ' +exc) ); }, 600 )
168 |
169 |
170 |
171 |
172 | if
173 | false
174 |
175 |
176 |
177 | getEval
178 | setTimeout( ()=>{selenium.callBackOutFlow( 'func', 'shouldFail=false').then( (value)=>alert('success from JS: ' +value), (exc)=>alert('failure from JS: ' +exc) ); }, 600 )
179 |
180 |
181 |
182 | endIf
183 |
184 |
185 |
186 |
187 |
188 |
189 |
--------------------------------------------------------------------------------
/sel-blocksTests/_SelBlocks-regression.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Test Suite
7 |
8 |
9 |
10 | Test Suite
11 | README
12 | eval
13 | label-issue2
14 | branching01
15 | branching02
16 | if01
17 | if02
18 | if03
19 | for
20 | foreach
21 | foreach-xpath
22 | forjson
23 | loadjsonvars
24 | forxml
25 | loadxmlvars
26 | continue-break01
27 | continue-break02
28 | continue-break03
29 | continue-break04
30 | nested-loops
31 | function01
32 | function02
33 | function03-recursive
34 | function04-issue2
35 | function05-scoping-issue5
36 | exitTest01
37 | exitTest02 - from within a loop
38 | exitTest03 - from within a function
39 | try01 - no-op try
40 | try02 - try-finally, w-no error
41 | try03 - try-catch, but no error
42 | try04 - catch specific error
43 | try05 - catch specific error, then finally
44 | try06 - catch-throw, finally-throw
45 | try07 - bubble up to catch ALL
46 | try08 - bubble up to catch ALL via finally
47 | try09 - bubble out of no-op try to catch specific error
48 | try10 - bubble up to catch specific error
49 | try11 - bubble up to catch specific error via finally
50 | try12 - throw, catch, rethrow
51 | try13 - bubble out of nested function calls
52 | try14 - command bubbling, break wfinally
53 | try15 - command bubbling, intra-try break
54 | try16 - command bubbling, continue w-finally
55 | try17 - command bubbling, intra-try continue
56 | try18 - command bubbling, error replaced by return
57 | try19 - command bubbling, error replaced by throw
58 | try20 - command bubbling, return replaced by error
59 | try21 - catch failed verify command
60 | try22 - exitTest w-finally processing
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/smoketest.side:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | smoketest
8 |
9 |
10 |
11 |
12 | eval
13 |
14 |
15 |
16 |
17 | skipNext
18 |
19 |
20 |
21 |
22 | getEval
23 | "this command skpped because of skipNext"
24 |
25 |
26 |
27 | goto
28 | HERE
29 |
30 |
31 |
32 | getEval
33 | "this command skpped because of goto"
34 |
35 |
36 |
37 | label
38 | HERE
39 |
40 |
41 |
42 | gotoIf
43 | true
44 | THERE
45 |
46 |
47 | getEval
48 | "this command skpped because of gotoIf true"
49 |
50 |
51 |
52 | label
53 | THERE
54 |
55 |
56 |
57 |
58 | if
59 | false
60 |
61 |
62 |
63 | getEval
64 | "this command skpped because of if false"
65 |
66 |
67 |
68 | elseIf
69 | true
70 |
71 |
72 |
73 | getEval
74 | "this command executes because of elseIf true"
75 |
76 |
77 |
78 | elseIf
79 | true
80 |
81 |
82 |
83 | getEval
84 | "this command skpped because of previous elseIf"
85 |
86 |
87 |
88 | endIf
89 |
90 |
91 |
92 |
93 |
94 | try
95 |
96 |
97 |
98 |
99 | getEval
100 | "trying"
101 |
102 |
103 |
104 | throw
105 | "test error"
106 |
107 |
108 |
109 | assertEval
110 | "this command should not be reached because of throw"
111 |
112 |
113 |
114 | catch
115 | /test error/
116 |
117 |
118 |
119 | getEval
120 | "CAUGHT '${_error.message}'"
121 |
122 |
123 |
124 | finally
125 |
126 |
127 |
128 |
129 | getEval
130 | "this command executes no matter how above error processing turns out"
131 |
132 |
133 |
134 | endTry
135 |
136 |
137 |
138 |
139 |
140 | store
141 | 3
142 | w
143 |
144 |
145 | while
146 | w > 0
147 |
148 |
149 |
150 | getEval
151 | "iter=${w}"
152 |
153 |
154 |
155 | storeEval
156 | ${w}-1
157 | w
158 |
159 |
160 | endWhile
161 |
162 |
163 |
164 |
165 |
166 | for
167 | f=3; f <= 9; f++
168 |
169 |
170 |
171 | continue
172 | f == 6
173 |
174 |
175 |
176 | if
177 | f > 6
178 |
179 |
180 |
181 | if
182 | f == 7
183 |
184 |
185 |
186 | continue
187 |
188 |
189 |
190 |
191 | else
192 |
193 |
194 |
195 |
196 | break
197 |
198 |
199 |
200 |
201 | endIf
202 |
203 |
204 |
205 |
206 | endIf
207 |
208 |
209 |
210 |
211 | getEval
212 | "iter=${f}"
213 |
214 |
215 |
216 | endFor
217 |
218 |
219 |
220 |
221 |
222 | function
223 | doSomething
224 | sname
225 |
226 |
227 | getEval
228 | "sname=${sname},srole=${srole}"
229 |
230 |
231 |
232 | endFunction
233 | doSomething
234 |
235 |
236 |
237 | foreach
238 | sname
239 | "asok", "alice"
240 |
241 |
242 | call
243 | doSomething
244 | sname = sname, srole = "super=user"
245 |
246 |
247 | endForeach
248 |
249 |
250 |
251 |
252 |
253 |
254 |
--------------------------------------------------------------------------------
/sel-blocks-fx_xpi/chrome/content/extensions/browser.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var EXPORTED_SYMBOLS= ['Flag'];
3 |
4 | // I access this file in two ways: from browser.xul, and also as a JS code module via Components.utils.import(), importing itself when invoked from browser.xul. Following if() tells me how this file is being accessed.
5 | if( typeof window!=='undefined' ) {
6 | // Anonymous function puts variables into local scope. Otherwise I had symbols 'thisAddOnChrome' and function showAlert shared across multiple SeLite add-ons, which caused problems when showAlert() shows delayed.
7 | ( function() {
8 | var thisAddOnID= 'selblocks-global@selite.googlecode.com';
9 | var thisAddOnChrome= 'chrome://selite-selblocks-global';
10 |
11 | /** Following code should be the same across all SeLite extensions that need Extension Sequencer. */
12 | var showAlert= function showAlert( ){
13 | /* I can't use window.alert(..) here. gBrowser is defined here, however gBrowser.addTab(..) failed when I called it from right here. Therefore I delay it and then I can use either window.alert() or gBrowser.
14 | I tried to follow https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Alerts_and_Notifications and https://bugzilla.mozilla.org/show_bug.cgi?id=324570 and I've tried to show a non-modal popup. However, none of those methods works on Windows for multiple popups at the same time: then neither popup shows up. I've tried to use different titles for the popups. I've also tried http://notifications.spec.whatwg.org/#tags-example with different tags for the popups. None of that works.
15 | It can happen that another XPI also wants to show up a popup. Therefore I use gBrowser.selectedTab = gBrowser.addTab( url ).
16 | */
17 | window.setTimeout( function() {
18 | /*
19 | try {
20 | Components.classes['@mozilla.org/alerts-service;1'].
21 | getService(Components.interfaces.nsIAlertsService).
22 | showAlertNotification(null, title, msg, false, '', null);
23 | } catch(e) {
24 | var win = Components.classes['@mozilla.org/embedcomp/window-watcher;1'].
25 | getService(Components.interfaces.nsIWindowWatcher).
26 | openWindow(null, 'chrome://global/content/alerts/alert.xul',
27 | '_blank', 'chrome,titlebar=no,popup=yes', null);
28 | win.arguments = [null, title, msg, false, ''];
29 | }*/
30 | gBrowser.selectedTab = gBrowser.addTab( thisAddOnChrome +'/content/extensions/extension_sequencer_missing.xul' );
31 | }, 3000 );
32 | };
33 | try {
34 | // Test presence of Extension Sequencer
35 | Components.utils.import("chrome://selite-extension-sequencer/content/SeLiteExtensionSequencer.js");
36 | }
37 | catch(e) {
38 | // Load this file itself as a JS code module, so that it shares Flag object across windows:
39 | var sharedScope= {};
40 | Components.utils.import( thisAddOnChrome+ "/content/extensions/browser.js", sharedScope );
41 | if( !sharedScope.Flag.alertShown ) {
42 | Components.utils.import("resource://gre/modules/AddonManager.jsm");
43 | AddonManager.getAllAddons(
44 | function( addons ) {
45 | // I sort the add-ons alphabetically by ID. I want to show only one alert even if there are multiple SeLite XPIs or other XPIs that use Extension Sequencer.So I show the alert in the add-on which is the first on the list of SeLite add-ons (when sorted by ID in the alphabetical order).
46 | var seliteAddOnIDs= [];
47 | // Following are IDs of SeLite add-ons that can be (easily) used without Extension Sequencer. Those add-ons don't report whether Extension Sequencer is missing, so I don't add them to seliteAddOnsIDs.
48 | var addOnIDsNotNeedingSequencer= ['misc@selite.googlecode.com', 'settings@selite.googlecode.com', 'sqlite-connection-manager@selite.googlecode.com']; // @TODO use: const
49 | for( var i=0; i0 || addon.id===thisAddOnID ) // addon.id===thisAddOnID serves if this addon is not an SeLite add-on.
53 | && addOnIDsNotNeedingSequencer.indexOf(addon.id)<0
54 | ) {
55 | seliteAddOnIDs.push( addon.id );
56 | }
57 | }
58 | seliteAddOnIDs.sort();
59 | if( seliteAddOnIDs[0]===thisAddOnID ) {
60 | showAlert();
61 | sharedScope.Flag.alertShown= true;
62 | }
63 | }
64 | );
65 | }
66 | }
67 | } )();
68 | }
69 | else {
70 | var Flag= {
71 | alertShown: false // Whether I've already shown the alert (potentially in another window). It helps me to ensure that I don't show the same message again if the user opens a new window.
72 | };
73 | }
--------------------------------------------------------------------------------
/notes/Mozilla-page.txt:
--------------------------------------------------------------------------------
1 | ================================================================================
2 | SelBlocks (for Selenium IDE) 2.1
3 | by refactoror
4 |
5 | Latest version 2.1
6 |
7 | -limit 250 characters-
8 | This is an extension for Selenium IDE that provides javascript-like conditionals, looping, callable functions, error catching, and JSON/XML driven parameterization.
9 |
10 | ================================================================================
11 | About this Add-on
12 |
13 | SelBlocks 2
14 |
15 | Adds the following "block" structures to Selenese:
16 |
17 | if, elseIf, else
18 | try, catch, finally, throw
19 | for, foreach, while, continue, break
20 | call, function, return
21 | loadJsonVars, loadXmlVars, forJson, forXml
22 | exitTest
23 |
24 |
25 | Command parameters are javascript expressions that are evaluated with Selenium variables in scope, which can therefore be referenced by their simple names, e.g.: i+1
26 |
27 | Function and loop parameters use regular Selenium variables that are local to the block, overriding variables of the same name, and that are restored when the block exits.
28 |
29 | Errors bubble upward through try/catch/finally blocks, which can be nested arbitrarily. Catching an error cancels it, but can be re-thrown.
30 |
31 | Variables can be configured via external XML and/or JSON files.
32 |
33 | A function definition can appear anywhere, (they are skipped over in normal execution flow).
34 |
35 | Functions can be called recursively.
36 |
37 |
38 |
39 | Note that it take months for Mozilla to review each addon update. For compatibility with Firefox versions above 17, see: https://addons.mozilla.org/en-US/firefox/addon/selenium-ide-sel-blocks/versions/
40 |
41 | Documentation / Support
42 |
43 | ================================================================================
44 | Version 2.1
45 | Released ...
46 |
47 | Changes since 2.0.2:
48 | ** Added support for Selenium Server. (A big thanks to Matthew Kastor)
49 | ** Added ability to catch verify command faliures
50 | ** Issue #6: Fix for try/catch not clearing error status
51 | ** Issue #11: Fix for top-level try/finally leaves Selenium IDE in running mode
52 | ** Issue #12: Fix for unhandled try/catch in one test affects next test
53 |
54 | ================================================================================
55 | Version 2.0.2
56 | Released ...
57 |
58 | Changes since 2.0.1:
59 | * Issue#2: Fix for cases where function or label are the first command
60 |
61 | ================================================================================
62 | Version 2.0.1
63 | Released February 13, 2014 33.1 KB
64 | Works with Firefox 17.0 and later
65 |
66 | Changes since 2.0:
67 | * Check for multiple un-terminated blocks
68 | * Removed Array.iterator()
69 | * Added detail to About dialog
70 | * Miscellaneous jsLint cleanups
71 | * Provide test script for Mozilla reviewers (smoketest.side)
72 |
73 | ================================================================================
74 | Version 2.0
75 | Released October 28, 2013 31.0 KB
76 | Works with Firefox 17.0 and later
77 |
78 | Changes since 1.5:
79 | * New commands: elseIf and try/catch/finally/throw
80 | * Block boundaries enforced (jumping in-to and/or out-of the middle of blocks)
81 | * Deprecated script/endScript, use function/endFunction instead
82 | * Implicit initialization of for loop variable(s)
83 | * Improved validation of command expressions
84 |
85 | ================================================================================
86 | Version 1.5
87 | Released September 8, 2013 25.4 KB
88 | Works with Firefox 10.0 and later
89 |
90 | Changes since 1.3.1:
91 | * New commands: loadJsonVars, forJson, and exitTest
92 | * Expression parsing is more robust, for & call list parameters in particular
93 | * Variable and parameter names are validated for alphanumeric conventions
94 | * Logging identifies itself with the prefix [SelBlocks]
95 | * Internal functions & vars no longer pollute the global Javascript name space
96 |
97 | Thanks to Martin Bramwell for JSON proof of concept.
98 |
99 | --------------------------------------------------------------------------------
100 | Version 1.3
101 | Released August 14, 2011 10.2 KB
102 | Works with Firefox 1.5 and later
103 |
104 | Changes since 1.2:
105 | * Added continue & break for loops
106 |
107 | Works with Selenium 1.0 and 1.1, on Firefox 5, 6, and 7
108 |
109 | --------------------------------------------------------------------------------
110 | Version 1.1
111 | Released April 10, 2011 9.2 KB
112 | Works with Firefox 1.5 and later
113 |
114 | Changes since 1.0:
115 | * Fixed branch-to bug where label or block starts on the first line of the script.
116 | * Fixed foreach bug: input values not being evaluated with stored variables.
117 | * Added automatic variable ${_i} inside foreach loop: zero-based item index.
118 | * Added $X(xpath) for retrieving an array of matching elements.
119 | * Eliminated warn logging of selenium hook setup, etc, changed to debug level.
120 |
--------------------------------------------------------------------------------