~vasilev/psiphon/sprint3-579678

« back to all changes in this revision

Viewing changes to trunk/testing/selenium_scripts/selenium/coding-conventions.txt

  • Committer: Adam Pritchard
  • Date: 2010-07-16 19:31:33 UTC
  • mfrom: (95.1.8 testing-2.5)
  • Revision ID: adam@adampsidev-20100716193133-n6rxnrqwt68d0ck8
Made Selenium work; added some tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
            Coding standards for Selenium Core Javascript code
2
 
            --------------------------------------------------
3
 
 
4
 
  Here is a set of conventions agreed by the active Selenium Core
5
 
  developers at ThoughtWorks.  Please stick to these guidelines when
6
 
  working on the Selenium Core code-base.
7
 
 
8
 
Whitespace: we use spaces, NOT TABS.  Indent in 4-space increments.
9
 
 
10
 
Braces: we place open-braces on the same line as the associated keyword,
11
 
  for example:
12
 
 
13
 
        if (command.isBreakpoint) {
14
 
            this.pause();
15
 
        } else {
16
 
            window.setTimeout(this.resume.bind(this), delay);
17
 
        }
18
 
 
19
 
Encapsulation: we prefer to encapsulate functions and variables inside
20
 
  objects, where possible.
21
 
 
22
 
Variable declarations: declare variables (using "var") ... even if they're
23
 
  "global".
24
 
 
25
 
Class definitions: we're shifting to "prototype.js" style for
26
 
  definition of classes, e.g.
27
 
 
28
 
        var MyClass = Class.create();
29
 
        Object.extend(MyClass.prototype, {
30
 
        
31
 
            initialize: function() {
32
 
                // ... constructor code ...
33
 
            },
34
 
        
35
 
            doStuff: function() {
36
 
                // ... method body ...
37
 
            }
38
 
        
39
 
        });
40
 
 
41
 
'Private' functions/properties: we simulate "private" properties by
42
 
  prepended the name with an underscore ("_"), e.g.
43
 
 
44
 
        _resumeAfterDelay : function() {
45
 
            // ...etc...
46
 
        },
47
 
 
48
 
Element addressing: use "$(id)" rather than
49
 
  "document.getElementById('id')".
50
 
 
51
 
Timeout functions: pass function objects to setTimeout(), rather than
52
 
  strings, e.g.
53
 
 
54
 
        window.setTimeout(this.resume.bind(this), delay);
 
1
            Coding standards for Selenium Core Javascript code
 
2
            --------------------------------------------------
 
3
 
 
4
  Here is a set of conventions agreed by the active Selenium Core
 
5
  developers at ThoughtWorks.  Please stick to these guidelines when
 
6
  working on the Selenium Core code-base.
 
7
 
 
8
Whitespace: we use spaces, NOT TABS.  Indent in 4-space increments.
 
9
 
 
10
Braces: we place open-braces on the same line as the associated keyword,
 
11
  for example:
 
12
 
 
13
        if (command.isBreakpoint) {
 
14
            this.pause();
 
15
        } else {
 
16
            window.setTimeout(this.resume.bind(this), delay);
 
17
        }
 
18
 
 
19
Encapsulation: we prefer to encapsulate functions and variables inside
 
20
  objects, where possible.
 
21
 
 
22
Variable declarations: declare variables (using "var") ... even if they're
 
23
  "global".
 
24
 
 
25
Class definitions: we're shifting to "prototype.js" style for
 
26
  definition of classes, e.g.
 
27
 
 
28
        var MyClass = Class.create();
 
29
        Object.extend(MyClass.prototype, {
 
30
        
 
31
            initialize: function() {
 
32
                // ... constructor code ...
 
33
            },
 
34
        
 
35
            doStuff: function() {
 
36
                // ... method body ...
 
37
            }
 
38
        
 
39
        });
 
40
 
 
41
'Private' functions/properties: we simulate "private" properties by
 
42
  prepended the name with an underscore ("_"), e.g.
 
43
 
 
44
        _resumeAfterDelay : function() {
 
45
            // ...etc...
 
46
        },
 
47
 
 
48
Element addressing: use "$(id)" rather than
 
49
  "document.getElementById('id')".
 
50
 
 
51
Timeout functions: pass function objects to setTimeout(), rather than
 
52
  strings, e.g.
 
53
 
 
54
        window.setTimeout(this.resume.bind(this), delay);