lib/commands/marionette/cookie.js

Maintainability

52.99

Lines of code

80

Created with Raphaël 2.1.002550751002014-3-30

2014-3-30
Maintainability: 52.99

Created with Raphaël 2.1.00204060802014-3-30

2014-3-30
Lines of Code: 80

Difficulty

8.22

Estimated Errors

0.17

Function weight

By Complexity

Created with Raphaël 2.1.0module.exports1

By SLOC

Created with Raphaël 2.1.0module.exports69
1
/*!
2
 *
3
 * Copyright (c) 2013 Sebastian Golasch
4
 *
5
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * copy of this software and associated documentation files (the "Software"),
7
 * to deal in the Software without restriction, including without limitation
8
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 * and/or sell copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following conditions:
11
 *
12
 * The above copyright notice and this permission notice shall be included
13
 * in all copies or substantial portions of the Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
 * DEALINGS IN THE SOFTWARE.
22
 *
23
 */
24
 
25
'use strict';
26
 
27
/**
28
 * Cookie related Marionette commands
29
 * see [JsonProtocol](https://wiki.mozilla.org/Auto-tools/Projects/Marionette/JSON_Protocol)
30
 *
31
 * @module FirefoxDriver
32
 * @class Cookie
33
 * @namespace FirefoxDriver.Commands.Marionette
34
 */
35
 
36
module.exports = function (Marionette) {
37
 
38
  /**
39
   * Retrieve all cookies visible to the current page.
40
   *
41
   * @method getCookies
42
   */
43
 
44
  Marionette.addCommand({
45
    name: 'getCookies',
46
    request: {
47
      to: ':marionetteId',
48
      session: ':sessionId',
49
      name: 'getAllCookies'
50
    }
51
  });
52
 
53
  /**
54
   * Delete all cookies visible to the current page.
55
   *
56
   * @method deleteCookies
57
   */
58
 
59
  Marionette.addCommand({
60
    name: 'deleteCookies',
61
    request: {
62
      to: ':marionetteId',
63
      session: ':sessionId',
64
      name: 'deleteAllCookies'
65
    }
66
  });
67
 
68
  /**
69
   * Delete the cookie with the given name.
70
   * This command should be a no-op if there is no such cookie visible to the current page.
71
   *
72
   * @method deleteCookie
73
   */
74
 
75
  Marionette.addCommand({
76
    name: 'deleteCookie',
77
    request: {
78
      to: ':marionetteId',
79
      session: ':sessionId',
80
      name: 'deleteCookie',
81
      parameters: {
82
        name: ':name',
83
      }
84
    }
85
  });
86
 
87
  /**
88
   * Set a cookie. If the cookie path is not specified, it should be set to "/".
89
   * Likewise, if the domain is omitted, it should default to the current page's domain.
90
   *
91
   * @method addCookie
92
   */
93
 
94
  Marionette.addCommand({
95
    name: 'cookies',
96
    request: {
97
      to: ':marionetteId',
98
      session: ':sessionId',
99
      cookie: ':cookie',
100
      name: 'addCookie'
101
    }
102
  });
103
 
104
};