[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/mullvad-browser][mullvad-browser-115.11.0esr-13.5-1] 2 commits: Revert "Bug 41881: Don't persist custom network requests on private windows"



Title: GitLab

richard pushed to branch mullvad-browser-115.11.0esr-13.5-1 at The Tor Project / Applications / Mullvad Browser

Commits:

  • bea39ca4
    by Pier Angelo Vendrame at 2024-05-13T20:40:44+00:00
    Revert "Bug 41881: Don't persist custom network requests on private windows"
    
    This reverts commit 6450a4e62e810832f35ee8732a4630ec2c2ba6f6.
    
  • 400cba03
    by cypherpunks1 at 2024-05-13T20:40:45+00:00
    Bug 1892052 - Do not persist custom network requests on PBM. r=devtools-reviewers,bomsy,nchevobbe
    
    Differential Revision: https://phabricator.services.mozilla.com/D207762

3 changed files:

Changes:

  • devtools/client/netmonitor/src/components/new-request/HTTPCustomRequestPanel.js
    ... ... @@ -4,11 +4,6 @@
    4 4
     
    
    5 5
     "use strict";
    
    6 6
     
    
    7
    -const lazy = {};
    
    8
    -ChromeUtils.defineESModuleGetters(lazy, {
    
    9
    -  PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
    
    10
    -});
    
    11
    -
    
    12 7
     const {
    
    13 8
       Component,
    
    14 9
       createFactory,
    
    ... ... @@ -127,7 +122,7 @@ class HTTPCustomRequestPanel extends Component {
    127 122
     
    
    128 123
       async componentDidMount() {
    
    129 124
         let { connector, request } = this.props;
    
    130
    -    if (!lazy.PrivateBrowsingUtils.isWindowPrivate(window)) {
    
    125
    +    if (!connector.currentTarget?.targetForm?.isPrivate) {
    
    131 126
           const persistedCustomRequest = await asyncStorage.getItem(
    
    132 127
             "devtools.netmonitor.customRequest"
    
    133 128
           );
    
    ... ... @@ -198,7 +193,7 @@ class HTTPCustomRequestPanel extends Component {
    198 193
       }
    
    199 194
     
    
    200 195
       componentWillUnmount() {
    
    201
    -    if (!lazy.PrivateBrowsingUtils.isWindowPrivate(window)) {
    
    196
    +    if (!this.props.connector.currentTarget?.targetForm?.isPrivate) {
    
    202 197
           asyncStorage.setItem("devtools.netmonitor.customRequest", this.state);
    
    203 198
         }
    
    204 199
       }
    

  • devtools/client/netmonitor/test/browser_net_new_request_panel_persisted_content.js
    ... ... @@ -9,30 +9,14 @@ const asyncStorage = require("resource://devtools/shared/async-storage.js");
    9 9
      * Test if content is still persisted after the panel is closed
    
    10 10
      */
    
    11 11
     
    
    12
    -add_task(async function () {
    
    13
    -  // Turn true the pref
    
    14
    -  await pushPref("devtools.netmonitor.features.newEditAndResend", true);
    
    15
    -  // Reset the storage for the persisted custom request
    
    16
    -  await asyncStorage.removeItem("devtools.netmonitor.customRequest");
    
    17
    -
    
    18
    -  const { monitor } = await initNetMonitor(HTTPS_CUSTOM_GET_URL, {
    
    19
    -    requestCount: 1,
    
    20
    -  });
    
    21
    -  info("Starting test... ");
    
    22
    -
    
    23
    -  const { document, store, windowRequire } = monitor.panelWin;
    
    24
    -
    
    25
    -  // Action should be processed synchronously in tests.
    
    26
    -  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
    
    27
    -  store.dispatch(Actions.batchEnable(false));
    
    28
    -
    
    29
    -  info("open the left panel");
    
    30
    -  let waitForPanels = waitForDOM(
    
    12
    +async function addCustomRequestTestContent(tab, monitor, document) {
    
    13
    +  info("Open the left panel");
    
    14
    +  const waitForPanels = waitForDOM(
    
    31 15
         document,
    
    32 16
         ".monitor-panel .network-action-bar"
    
    33 17
       );
    
    34 18
     
    
    35
    -  let HTTPCustomRequestButton = document.querySelector(
    
    19
    +  const HTTPCustomRequestButton = document.querySelector(
    
    36 20
         "#netmonitor-toolbar-container .devtools-http-custom-request-icon"
    
    37 21
       );
    
    38 22
       HTTPCustomRequestButton.click();
    
    ... ... @@ -59,91 +43,166 @@ add_task(async function () {
    59 43
         "#http-custom-query .map-add-new-inputs .http-custom-input-name"
    
    60 44
       );
    
    61 45
       newParameterName.focus();
    
    62
    -  EventUtils.sendString("My-param");
    
    46
    +  EventUtils.sendString("My-param", monitor.panelWin);
    
    63 47
     
    
    64 48
       info("Adding new headers");
    
    65 49
       const newHeaderName = document.querySelector(
    
    66 50
         "#http-custom-headers .map-add-new-inputs .http-custom-input-name"
    
    67 51
       );
    
    68 52
       newHeaderName.focus();
    
    69
    -  EventUtils.sendString("My-header");
    
    53
    +  EventUtils.sendString("My-header", monitor.panelWin);
    
    70 54
     
    
    71 55
       const newHeaderValue = Array.from(
    
    72 56
         document.querySelectorAll(
    
    73 57
           "#http-custom-headers .http-custom-input .http-custom-input-value"
    
    74 58
         )
    
    75
    -  ).pop();
    
    59
    +  ).at(-1);
    
    76 60
       newHeaderValue.focus();
    
    77
    -  EventUtils.sendString("my-value");
    
    61
    +  EventUtils.sendString("my-value", monitor.panelWin);
    
    78 62
     
    
    79 63
       const postValue = document.querySelector("#http-custom-postdata-value");
    
    80 64
       postValue.focus();
    
    81
    -  EventUtils.sendString("{'Name': 'Value'}");
    
    65
    +  EventUtils.sendString("{'Name': 'Value'}", monitor.panelWin);
    
    82 66
     
    
    83
    -  // Close the panel
    
    67
    +  info("Close the panel");
    
    84 68
       const closePanel = document.querySelector(
    
    85 69
         ".network-action-bar .tabs-navigation .sidebar-toggle"
    
    86 70
       );
    
    87 71
       closePanel.click();
    
    72
    +}
    
    88 73
     
    
    89
    -  // Open the panel again to see if the content is still there
    
    90
    -  waitForPanels = waitUntil(
    
    74
    +async function runTests(tab, monitor, document, isPrivate = false) {
    
    75
    +  info("Open the panel again to see if the content is still there");
    
    76
    +  const waitForPanels = waitFor(
    
    91 77
         () =>
    
    92 78
           document.querySelector(".http-custom-request-panel") &&
    
    93 79
           document.querySelector("#http-custom-request-send-button").disabled ===
    
    94
    -        false
    
    80
    +        isPrivate
    
    95 81
       );
    
    96 82
     
    
    97
    -  HTTPCustomRequestButton = document.querySelector(
    
    83
    +  const HTTPCustomRequestButton = document.querySelector(
    
    98 84
         "#netmonitor-toolbar-container .devtools-http-custom-request-icon"
    
    99 85
       );
    
    100 86
       HTTPCustomRequestButton.click();
    
    101 87
       await waitForPanels;
    
    102 88
     
    
    103
    -  is(
    
    104
    -    methodValue.value,
    
    105
    -    "POST",
    
    106
    -    "The content should still be there after the user close the panel and re-opened"
    
    107
    -  );
    
    108
    -
    
    109
    -  is(
    
    110
    -    url.value,
    
    111
    -    "https://www.example.com?My-param=",
    
    112
    -    "The url should still be there after the user close the panel and re-opened"
    
    113
    -  );
    
    89
    +  // Wait a few seconds to make sure all the fields have been updated
    
    90
    +  await wait(1500);
    
    91
    +
    
    92
    +  const customMethod = document.querySelector("#http-custom-method-value");
    
    93
    +  const customUrl = document.querySelector(".http-custom-url-value");
    
    94
    +  const customQuery = document.querySelectorAll(
    
    95
    +    "#http-custom-query .tabpanel-summary-container.http-custom-input textarea"
    
    96
    +  );
    
    97
    +  const customHeaders = document.querySelectorAll(
    
    98
    +    "#http-custom-headers .tabpanel-summary-container.http-custom-input textarea"
    
    99
    +  );
    
    100
    +  const postDataValue = document.querySelector("#http-custom-postdata-value");
    
    101
    +
    
    102
    +  if (isPrivate) {
    
    103
    +    is(
    
    104
    +      customMethod.value,
    
    105
    +      "GET",
    
    106
    +      "The method should not be persisted after the user close the panel and re-opened in PBM"
    
    107
    +    );
    
    108
    +
    
    109
    +    is(
    
    110
    +      customUrl.value,
    
    111
    +      "",
    
    112
    +      "The url should not be there after the user close the panel and re-opened in PBM"
    
    113
    +    );
    
    114
    +
    
    115
    +    is(
    
    116
    +      customQuery.length,
    
    117
    +      0,
    
    118
    +      "The Parameter should not be there after the user close the panel and re-opened in PBM"
    
    119
    +    );
    
    120
    +
    
    121
    +    is(
    
    122
    +      customHeaders.length,
    
    123
    +      0,
    
    124
    +      "There should be no custom headers after the user close the panel and re-opened in PBM"
    
    125
    +    );
    
    126
    +
    
    127
    +    is(
    
    128
    +      postDataValue.value,
    
    129
    +      "",
    
    130
    +      "The post data should still be reset after the user close the panel and re-opened in PBM"
    
    131
    +    );
    
    132
    +  } else {
    
    133
    +    is(
    
    134
    +      customMethod.value,
    
    135
    +      "POST",
    
    136
    +      "The method should be persisted after the user close the panel and re-opened"
    
    137
    +    );
    
    138
    +
    
    139
    +    is(
    
    140
    +      customUrl.value,
    
    141
    +      "https://www.example.com?My-param=",
    
    142
    +      "The url should still be there after the user close the panel and re-opened"
    
    143
    +    );
    
    144
    +
    
    145
    +    const [nameParam] = Array.from(customQuery);
    
    146
    +    is(
    
    147
    +      nameParam.value,
    
    148
    +      "My-param",
    
    149
    +      "The Parameter name should still be there after the user close the panel and re-opened"
    
    150
    +    );
    
    151
    +
    
    152
    +    const [name, value] = Array.from(customHeaders);
    
    153
    +    is(
    
    154
    +      name.value,
    
    155
    +      "My-header",
    
    156
    +      "The header name should still be there after the user close the panel and re-opened"
    
    157
    +    );
    
    158
    +    is(
    
    159
    +      value.value,
    
    160
    +      "my-value",
    
    161
    +      "The header value should still be there after the user close the panel and re-opened"
    
    162
    +    );
    
    163
    +
    
    164
    +    is(
    
    165
    +      postDataValue.value,
    
    166
    +      "{'Name': 'Value'}",
    
    167
    +      "The content should still be there after the user close the panel and re-opened"
    
    168
    +    );
    
    169
    +  }
    
    170
    +}
    
    171
    +
    
    172
    +add_task(async function testRequestPanelPersistedContent() {
    
    173
    +  // Turn true the pref
    
    174
    +  await pushPref("devtools.netmonitor.features.newEditAndResend", true);
    
    175
    +  // Reset the storage for the persisted custom request
    
    176
    +  await asyncStorage.removeItem("devtools.netmonitor.customRequest");
    
    114 177
     
    
    115
    -  const [nameParam] = Array.from(
    
    116
    -    document.querySelectorAll(
    
    117
    -      "#http-custom-query .tabpanel-summary-container.http-custom-input textarea"
    
    118
    -    )
    
    119
    -  );
    
    120
    -  is(
    
    121
    -    nameParam.value,
    
    122
    -    "My-param",
    
    123
    -    "The Parameter name should still be there after the user close the panel and re-opened"
    
    124
    -  );
    
    178
    +  const { tab, monitor } = await initNetMonitor(HTTPS_CUSTOM_GET_URL, {
    
    179
    +    requestCount: 1,
    
    180
    +  });
    
    181
    +  const { document, store, windowRequire } = monitor.panelWin;
    
    182
    +  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
    
    183
    +  store.dispatch(Actions.batchEnable(false));
    
    125 184
     
    
    126
    -  const [name, value] = Array.from(
    
    127
    -    document.querySelectorAll(
    
    128
    -      "#http-custom-headers .tabpanel-summary-container.http-custom-input textarea"
    
    129
    -    )
    
    130
    -  );
    
    131
    -  is(
    
    132
    -    name.value,
    
    133
    -    "My-header",
    
    134
    -    "The header name should still be there after the user close the panel and re-opened"
    
    135
    -  );
    
    136
    -  is(
    
    137
    -    value.value,
    
    138
    -    "my-value",
    
    139
    -    "The header value should still be there after the user close the panel and re-opened"
    
    140
    -  );
    
    185
    +  info("Starting test... ");
    
    186
    +  info("Add initial custom request test content");
    
    187
    +  await addCustomRequestTestContent(tab, monitor, document);
    
    188
    +  await runTests(tab, monitor, document);
    
    189
    +  await teardown(monitor);
    
    190
    +});
    
    141 191
     
    
    142
    -  is(
    
    143
    -    postValue.value,
    
    144
    -    "{'Name': 'Value'}",
    
    145
    -    "The content should still be there after the user close the panel and re-opened"
    
    192
    +add_task(async function testRequestPanelPersistedContentInPrivateWindow() {
    
    193
    +  await pushPref("devtools.netmonitor.features.newEditAndResend", true);
    
    194
    +  const { tab, monitor, privateWindow } = await initNetMonitor(
    
    195
    +    HTTPS_CUSTOM_GET_URL,
    
    196
    +    {
    
    197
    +      requestCount: 1,
    
    198
    +      openInPrivateWindow: true,
    
    199
    +    }
    
    146 200
       );
    
    201
    +  const { document, store, windowRequire } = monitor.panelWin;
    
    202
    +  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
    
    203
    +  store.dispatch(Actions.batchEnable(false));
    
    147 204
     
    
    148
    -  await teardown(monitor);
    
    205
    +  info("Starting test in private window... ");
    
    206
    +  await runTests(tab, monitor, document, true);
    
    207
    +  await teardown(monitor, privateWindow);
    
    149 208
     });

  • devtools/client/netmonitor/test/head.js
    ... ... @@ -321,6 +321,7 @@ function initNetMonitor(
    321 321
         expectedEventTimings,
    
    322 322
         waitForLoad = true,
    
    323 323
         enableCache = false,
    
    324
    +    openInPrivateWindow = false,
    
    324 325
       }
    
    325 326
     ) {
    
    326 327
       info("Initializing a network monitor pane.");
    
    ... ... @@ -341,7 +342,22 @@ function initNetMonitor(
    341 342
           ],
    
    342 343
         });
    
    343 344
     
    
    344
    -    const tab = await addTab(url, { waitForLoad });
    
    345
    +    let tab = null;
    
    346
    +    let privateWindow = null;
    
    347
    +
    
    348
    +    if (openInPrivateWindow) {
    
    349
    +      privateWindow = await BrowserTestUtils.openNewBrowserWindow({
    
    350
    +        private: true,
    
    351
    +      });
    
    352
    +      ok(
    
    353
    +        PrivateBrowsingUtils.isContentWindowPrivate(privateWindow),
    
    354
    +        "window is private"
    
    355
    +      );
    
    356
    +      tab = BrowserTestUtils.addTab(privateWindow.gBrowser, url);
    
    357
    +    } else {
    
    358
    +      tab = await addTab(url, { waitForLoad });
    
    359
    +    }
    
    360
    +
    
    345 361
         info("Net tab added successfully: " + url);
    
    346 362
     
    
    347 363
         const toolbox = await gDevTools.showToolboxForTab(tab, {
    
    ... ... @@ -371,7 +387,7 @@ function initNetMonitor(
    371 387
           await clearNetworkEvents(monitor);
    
    372 388
         }
    
    373 389
     
    
    374
    -    return { tab, monitor, toolbox };
    
    390
    +    return { tab, monitor, toolbox, privateWindow };
    
    375 391
       })();
    
    376 392
     }
    
    377 393
     
    
    ... ... @@ -408,7 +424,7 @@ async function clearNetworkEvents(monitor) {
    408 424
       store.dispatch(Actions.clearRequests());
    
    409 425
     }
    
    410 426
     
    
    411
    -function teardown(monitor) {
    
    427
    +function teardown(monitor, privateWindow) {
    
    412 428
       info("Destroying the specified network monitor.");
    
    413 429
     
    
    414 430
       return (async function () {
    
    ... ... @@ -419,6 +435,12 @@ function teardown(monitor) {
    419 435
     
    
    420 436
         await monitor.toolbox.destroy();
    
    421 437
         await removeTab(tab);
    
    438
    +
    
    439
    +    if (privateWindow) {
    
    440
    +      const closed = BrowserTestUtils.windowClosed(privateWindow);
    
    441
    +      privateWindow.BrowserCommands.tryToCloseWindow();
    
    442
    +      await closed;
    
    443
    +    }
    
    422 444
       })();
    
    423 445
     }
    
    424 446
     
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits