1
Coding standards for Selenium Core Javascript code
2
--------------------------------------------------
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.
8
Whitespace: we use spaces, NOT TABS. Indent in 4-space increments.
10
Braces: we place open-braces on the same line as the associated keyword,
13
if (command.isBreakpoint) {
16
window.setTimeout(this.resume.bind(this), delay);
19
Encapsulation: we prefer to encapsulate functions and variables inside
20
objects, where possible.
22
Variable declarations: declare variables (using "var") ... even if they're
25
Class definitions: we're shifting to "prototype.js" style for
26
definition of classes, e.g.
28
var MyClass = Class.create();
29
Object.extend(MyClass.prototype, {
31
initialize: function() {
32
// ... constructor code ...
36
// ... method body ...
41
'Private' functions/properties: we simulate "private" properties by
42
prepended the name with an underscore ("_"), e.g.
44
_resumeAfterDelay : function() {
48
Element addressing: use "$(id)" rather than
49
"document.getElementById('id')".
51
Timeout functions: pass function objects to setTimeout(), rather than
54
window.setTimeout(this.resume.bind(this), delay);
1
Coding standards for Selenium Core Javascript code
2
--------------------------------------------------
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.
8
Whitespace: we use spaces, NOT TABS. Indent in 4-space increments.
10
Braces: we place open-braces on the same line as the associated keyword,
13
if (command.isBreakpoint) {
16
window.setTimeout(this.resume.bind(this), delay);
19
Encapsulation: we prefer to encapsulate functions and variables inside
20
objects, where possible.
22
Variable declarations: declare variables (using "var") ... even if they're
25
Class definitions: we're shifting to "prototype.js" style for
26
definition of classes, e.g.
28
var MyClass = Class.create();
29
Object.extend(MyClass.prototype, {
31
initialize: function() {
32
// ... constructor code ...
36
// ... method body ...
41
'Private' functions/properties: we simulate "private" properties by
42
prepended the name with an underscore ("_"), e.g.
44
_resumeAfterDelay : function() {
48
Element addressing: use "$(id)" rather than
49
"document.getElementById('id')".
51
Timeout functions: pass function objects to setTimeout(), rather than
54
window.setTimeout(this.resume.bind(this), delay);