Browse Source

chore: fix patch linter (#21495)

Jeremy Apthorp 5 years ago
parent
commit
a90b5f8421
28 changed files with 85 additions and 16 deletions
  1. 4 1
      package.json
  2. 7 0
      patches/boringssl/expose_aes-cfb.patch
  3. 1 1
      patches/chromium/.patches
  4. 1 0
      patches/chromium/blink-worker-enable-csp-in-file-scheme.patch
  5. 2 0
      patches/chromium/blink_world_context.patch
  6. 9 0
      patches/chromium/build_gn.patch
  7. 4 0
      patches/chromium/can_create_window.patch
  8. 1 0
      patches/chromium/disable_hidden.patch
  9. 1 0
      patches/chromium/feat_allow_disabling_blink_scheduler_throttling_per_renderview.patch
  10. 2 0
      patches/chromium/gin_enable_disable_v8_platform.patch
  11. 2 0
      patches/chromium/network_service_allow_remote_certificate_verification_logic.patch
  12. 4 0
      patches/chromium/picture-in-picture.patch
  13. 1 0
      patches/chromium/render_widget_host_view_base.patch
  14. 5 12
      patches/chromium/render_widget_host_view_mac.patch
  15. 4 0
      patches/chromium/web_contents.patch
  16. 3 0
      patches/chromium/webview_cross_drag.patch
  17. 5 0
      patches/chromium/worker_context_will_destroy.patch
  18. 1 0
      patches/node/build_add_gn_build_files.patch
  19. 4 0
      patches/node/chore_handle_default_configuration_not_being_set_in_the_electron_env.patch
  20. 2 0
      patches/node/feat_add_new_built_with_electron_variable_to_config_gypi.patch
  21. 8 0
      patches/node/fix_call_initializecontextruntime_in_initializecontext.patch
  22. 1 0
      patches/node/fix_export_debugoptions.patch
  23. 2 0
      patches/node/fixme_comment_trace_event_macro.patch
  24. 2 0
      patches/node/fixme_remove_async_id_assertion_check.patch
  25. 2 0
      patches/node/refactor_allow_embedder_overriding_of_internal_fs_calls.patch
  26. 4 0
      patches/v8/build_gn.patch
  27. 1 0
      patches/v8/dcheck.patch
  28. 2 2
      script/lint.js

+ 4 - 1
package.json

@@ -130,6 +130,9 @@
       "python script/check-trailing-whitespace.py --fix",
       "git add filenames.auto.gni"
     ],
+    "{*.patch,.patches}": [
+      "node script/lint.js --patches --only --"
+    ],
     "DEPS": [
       "node script/gen-hunspell-filenames.js"
     ]
@@ -138,4 +141,4 @@
     "@types/multiparty": "^0.0.32",
     "@types/temp": "^0.8.34"
   }
-}
+}

+ 7 - 0
patches/boringssl/expose_aes-cfb.patch

@@ -3,6 +3,13 @@ From: Jeremy Apthorp <[email protected]>
 Date: Fri, 18 Jan 2019 14:23:28 -0800
 Subject: expose aes-{128,256}-cfb
 
+This exposes AES-CFB ciphers through the EVP APIs. BoringSSL has
+implementations for these ciphers, but Node doesn't realise that because
+without this patch, they're not listed in the APIs that Node uses.
+
+This should be upstreamed. See e.g.
+https://boringssl-review.googlesource.com/c/boringssl/+/33984 for a
+similar patch that was merged upstream.
 
 diff --git a/crypto/cipher_extra/cipher_extra.c b/crypto/cipher_extra/cipher_extra.c
 index b132265bc103658dba3de6e0c3dc50d3634da5b0..588a4773437c311877f275bf3679f9688cda3c46 100644

+ 1 - 1
patches/chromium/.patches

@@ -76,5 +76,5 @@ ignore_rc_check.patch
 remove_usage_of_incognito_apis_in_the_spellchecker.patch
 chore_use_electron_resources_not_chrome_for_spellchecker.patch
 add_trustedauthclient_to_urlloaderfactory.patch
-feat_allow_disbaling_blink_scheduler_throttling_per_renderview.patch
+feat_allow_disabling_blink_scheduler_throttling_per_renderview.patch
 accessible_pane_view.patch

+ 1 - 0
patches/chromium/blink-worker-enable-csp-in-file-scheme.patch

@@ -3,6 +3,7 @@ From: deepak1556 <[email protected]>
 Date: Thu, 20 Sep 2018 17:47:47 -0700
 Subject: blink-worker-enable-csp-in-file-scheme.patch
 
+This allows file:// URLs in workers to have a CSP.
 
 diff --git a/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc b/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc
 index 1f8273a782a5d3580e139d724ce8a791a100dcfb..90ad0d663003c0bded47183b61bff71a0c01a196 100644

+ 2 - 0
patches/chromium/blink_world_context.patch

@@ -3,6 +3,8 @@ From: Anonymous <[email protected]>
 Date: Thu, 20 Sep 2018 17:45:11 -0700
 Subject: blink_world_context.patch
 
+This exposes a method for obtaining a reference to an isolated world, which is
+otherwise not available in the Blink API.
 
 diff --git a/third_party/blink/public/web/web_local_frame.h b/third_party/blink/public/web/web_local_frame.h
 index 05a33b9a2cbed57e4e037428397b59f30f83ce66..0cd308b38a158a016b099beed6a31fa1c5a487ad 100644

+ 9 - 0
patches/chromium/build_gn.patch

@@ -3,6 +3,15 @@ From: Ales Pergl <[email protected]>
 Date: Thu, 20 Sep 2018 17:44:29 -0700
 Subject: build_gn.patch
 
+These are variables we add to the root BUILDCONFIG so that they're available
+everywhere, without having to import("//electron/.../flags.gni").
+
+Additionally, we add the `:mas_build` config to every compiled file so that
+the `MAS_BUILD` #define is available everywhere. This produces fewer patch
+conflicts when upgrading than it would if we added a specific config dependency
+only to those targets which had MAS_BUILD-relevant content in them. The
+tradeoff is that switching from MAS_BUILD to !MAS_BUILD or vice-versa will
+rebuild the entire tree.
 
 diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn
 index f89e7e831b79f82bd11a5dd8cee6ab49d8de724e..f8a611bf0676ce323cdbb5d639333df9875dd0ca 100644

+ 4 - 0
patches/chromium/can_create_window.patch

@@ -3,6 +3,10 @@ From: Cheng Zhao <[email protected]>
 Date: Thu, 20 Sep 2018 17:45:32 -0700
 Subject: can_create_window.patch
 
+This adds a hook to the window creation flow so that Electron can intercede and
+potentially prevent a window from being created.
+
+TODO(loc): this patch is currently broken.
 
 diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
 index 6e38ffd5a29e09d6214fab4013c7f4f8287f17c4..30e3604d100bb16680e4236c48cc4f32cb25ac61 100644

+ 1 - 0
patches/chromium/disable_hidden.patch

@@ -3,6 +3,7 @@ From: Cheng Zhao <[email protected]>
 Date: Thu, 20 Sep 2018 17:45:47 -0700
 Subject: disable_hidden.patch
 
+Electron uses this to disable background throttling for hidden windows.
 
 diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
 index a91a66bca29de8dc1e719f25c276fd33f2e4da20..3a20fad22d4e54192e1d9e4163ed4dc7d55d3324 100644

+ 1 - 0
patches/chromium/feat_allow_disbaling_blink_scheduler_throttling_per_renderview.patch → patches/chromium/feat_allow_disabling_blink_scheduler_throttling_per_renderview.patch

@@ -3,6 +3,7 @@ From: deepak1556 <[email protected]>
 Date: Fri, 29 Nov 2019 16:08:14 -0800
 Subject: feat: allow disabling blink scheduler throttling per RenderView
 
+This allows us to disable throttling for hidden windows.
 
 diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
 index 5304fc7951bc12c416e895b158210c0aa1a741c1..933eec28f206dfc8cb99ab0e87a62e6bd4084409 100644

+ 2 - 0
patches/chromium/gin_enable_disable_v8_platform.patch

@@ -3,6 +3,8 @@ From: Cheng Zhao <[email protected]>
 Date: Thu, 20 Sep 2018 17:47:44 -0700
 Subject: gin_enable_disable_v8_platform.patch
 
+We don't use gin to create the V8 platform, because we need to inject Node
+things.
 
 diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc
 index ee74e6ea92c64d0e95a4988557b236667f5b7e42..c3ae4c6221686479d05800c51d17d581c095e397 100644

+ 2 - 0
patches/chromium/network_service_allow_remote_certificate_verification_logic.patch

@@ -3,6 +3,8 @@ From: Jeremy Apthorp <[email protected]>
 Date: Wed, 8 May 2019 17:25:55 -0700
 Subject: network_service_allow_remote_certificate_verification_logic.patch
 
+This adds a callback from the network service that's used to implement
+session.setCertificateVerifyCallback.
 
 diff --git a/services/network/network_context.cc b/services/network/network_context.cc
 index 0d00958c9d318b9d1f34c0f1c1be1f6d6fa35d17..1e2d8401083906b5a07c9044cf72ea6d49a9edaa 100644

+ 4 - 0
patches/chromium/picture-in-picture.patch

@@ -3,6 +3,10 @@ From: Heilig Benedek <[email protected]>
 Date: Sat, 10 Aug 2019 00:41:50 +0200
 Subject: feat: enable picture in picture mode for video players
 
+These files are needed to implement PiP, but the Electron build patches out
+chrome's generated resources for our own. This updates the #include so that we
+don't get errors for Chrome's generated resources, which are non-existent
+because we don't generate them in our build.
 
 diff --git a/chrome/browser/ui/views/overlay/back_to_tab_image_button.cc b/chrome/browser/ui/views/overlay/back_to_tab_image_button.cc
 index 8e4deafa1746eeb48802a0503fefb37bedb33d04..127c62efd2327e1f3f09e9b93a0b8344e2714f80 100644

+ 1 - 0
patches/chromium/render_widget_host_view_base.patch

@@ -3,6 +3,7 @@ From: Anonymous <[email protected]>
 Date: Thu, 20 Sep 2018 17:46:21 -0700
 Subject: render_widget_host_view_base.patch
 
+... something to do with OSR? and maybe <webview> as well? terrifying.
 
 diff --git a/content/browser/renderer_host/render_widget_host_view_base.cc b/content/browser/renderer_host/render_widget_host_view_base.cc
 index 394b9ec0b7409465b0f9700a2d4a1eb1cf538e1f..a34dcdd124746b04d116e207b10395fc02649ec1 100644

+ 5 - 12
patches/chromium/render_widget_host_view_mac.patch

@@ -3,6 +3,11 @@ From: Cheng Zhao <[email protected]>
 Date: Thu, 20 Sep 2018 17:46:28 -0700
 Subject: render_widget_host_view_mac.patch
 
+This allows Electron to override `acceptsFirstMouse` on Mac so that windows can
+respond to the first mouse click in their window, which is desirable for some
+kinds of utility windows. Similarly for `disableAutoHideCursor`.
+
+Additionally, disables usage of some private APIs in MAS builds.
 
 diff --git a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
 index 320287e7cc5a2f11f135494a11e0a51d3818d41c..e88ed7afb6ea20c7a5cebba6cfe8c0b5fef1a52c 100644
@@ -65,15 +70,3 @@ index 320287e7cc5a2f11f135494a11e0a51d3818d41c..e88ed7afb6ea20c7a5cebba6cfe8c0b5
    }
    return validAttributesForMarkedText_.get();
  }
-diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
-index 275caf58aa73b1a775554753ad1ffe55fd93d45d..b6897c88c2c433e73f092f2ccebf29f097db35b0 100644
---- a/content/browser/renderer_host/render_widget_host_view_mac.mm
-+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
-@@ -63,6 +63,7 @@
- #include "ui/events/keycodes/dom/dom_keyboard_layout_map.h"
- #include "ui/gfx/geometry/dip_util.h"
- #include "ui/gfx/mac/coordinate_conversion.h"
-+#include "ui/gl/gpu_switching_manager.h"
- 
- using blink::WebInputEvent;
- using blink::WebMouseEvent;

+ 4 - 0
patches/chromium/web_contents.patch

@@ -3,6 +3,10 @@ From: Anonymous <[email protected]>
 Date: Thu, 20 Sep 2018 17:46:53 -0700
 Subject: web_contents.patch
 
+This allows overriding the RenderViewHostDelegateView of a WebContents, which
+is needed for OSR.
+
+Originally landed in https://github.com/electron/libchromiumcontent/pull/226.
 
 diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
 index d2697ed312a79c4e417bee7d613be4e349ca5819..49883d5a30b62e298a64349eeda5cddc4f339fd6 100644

+ 3 - 0
patches/chromium/webview_cross_drag.patch

@@ -3,6 +3,9 @@ From: Anonymous <[email protected]>
 Date: Thu, 20 Sep 2018 17:47:04 -0700
 Subject: webview_cross_drag.patch
 
+This allows dragging and dropping between <webview>s.
+
+Originally landed in https://github.com/electron/libchromiumcontent/pull/267
 
 diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc
 index 75972bb7f6ccfe5cf7d1bd78e154f7835312fda1..5368aafddd91cc75075700c8f93e3d7ea8f6435b 100644

+ 5 - 0
patches/chromium/worker_context_will_destroy.patch

@@ -3,6 +3,11 @@ From: Cheng Zhao <[email protected]>
 Date: Thu, 20 Sep 2018 17:47:12 -0700
 Subject: worker_context_will_destroy.patch
 
+This adds a hook for worker context destruction, which we use in Electron to
+shutdown node integration in the worker if relevant.
+
+An attempt to upstream this was made, but rejected:
+https://chromium-review.googlesource.com/c/chromium/src/+/1954347
 
 diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h
 index 6002ce70bb173f441f269ea2dc6e61716c424196..2c372d68dace9c546eae3bdbd4994ec261a6fa22 100644

+ 1 - 0
patches/node/build_add_gn_build_files.patch

@@ -3,6 +3,7 @@ From: Jeremy Apthorp <[email protected]>
 Date: Tue, 26 Feb 2019 17:07:45 -0800
 Subject: build: add GN build files
 
+This adds GN build files for Node, so we don't have to build with GYP.
 
 diff --git a/BUILD.gn b/BUILD.gn
 new file mode 100644

+ 4 - 0
patches/node/chore_handle_default_configuration_not_being_set_in_the_electron_env.patch

@@ -3,6 +3,10 @@ From: Samuel Attard <[email protected]>
 Date: Tue, 23 Jul 2019 11:36:48 -0700
 Subject: chore: handle default_configuration not being set in the electron env
 
+We don't set the `default_configuration` key in our config.gypi, this allows
+the tests to run in spite of that.
+
+TODO(marshallofsound/nornagon): Just add this key to config.gypi.
 
 diff --git a/test/common/index.js b/test/common/index.js
 index 00ebd283a0c3e960de2a7c4e3748561c499eb820..2ebec24f9e1f53306882e827a17925201cad0ea6 100644

+ 2 - 0
patches/node/feat_add_new_built_with_electron_variable_to_config_gypi.patch

@@ -3,6 +3,8 @@ From: Shelley Vohr <[email protected]>
 Date: Tue, 2 Oct 2018 11:39:58 -0700
 Subject: feat: add new built_with_electron variable to config.gypi
 
+This allows 3rd-party native modules to know whether they're being built
+against Electron.
 
 diff --git a/tools/generate_config_gypi.py b/tools/generate_config_gypi.py
 index 01f62d4ae6e3b9d539444e3dff069f0011353caa..d8b279f590c115108d5dca879747de7b0c9f1934 100644

+ 8 - 0
patches/node/fix_call_initializecontextruntime_in_initializecontext.patch

@@ -3,6 +3,14 @@ From: Shelley Vohr <[email protected]>
 Date: Tue, 22 Oct 2019 11:00:01 -0700
 Subject: fix: call InitializeContextRuntime in InitializeContext
 
+Since https://github.com/nodejs/node/commit/1ec4154e507ba71d7aefca0a6e5c155be34e989a,
+we observed a crash in renderer process initialization becuase we don't
+directly call NewContext, and so InitializeContext would not create primordials
+correctly and the following error would occur:
+
+node::Environment::CreateProperties(): Assertion `primordials->IsObject()' failed.
+
+This fixes that. See https://github.com/electron/electron/pull/20684.
 
 diff --git a/src/api/environment.cc b/src/api/environment.cc
 index 50886f4a998f1e7f346a6b7fad91ce49c3a7cdff..6ec07527ad7a806f889d884507e9def1cf68b4c8 100644

+ 1 - 0
patches/node/fix_export_debugoptions.patch

@@ -3,6 +3,7 @@ From: Nitish Sakhawalkar <[email protected]>
 Date: Thu, 11 Apr 2019 11:50:49 -0700
 Subject: fix: export DebugOptions
 
+This exports DebugOptions so we can parse args like `--inspect-brk`.
 
 diff --git a/src/node_options.cc b/src/node_options.cc
 index d53ab2a4bfe87321e899b431eac262223e532335..c0c15a88c028d9c70081aa75fabf63d1d78014e6 100644

+ 2 - 0
patches/node/fixme_comment_trace_event_macro.patch

@@ -3,6 +3,8 @@ From: Nitish Sakhawalkar <[email protected]>
 Date: Tue, 26 Mar 2019 11:28:05 -0700
 Subject: fixme: Comment trace event macro
 
+This broke the build at some point. Does it still? We should probably remove
+this patch and find out!
 
 diff --git a/src/node_internals.h b/src/node_internals.h
 index fb1188a6bbce37b2bbaba0a815f2826dca60cf3b..843cbf1d253022c9601ceaf74022873a48ac0a5f 100644

+ 2 - 0
patches/node/fixme_remove_async_id_assertion_check.patch

@@ -3,6 +3,8 @@ From: Shelley Vohr <[email protected]>
 Date: Thu, 13 Sep 2018 09:08:10 -0700
 Subject: FIXME: remove async_id assertion check
 
+async hooks are hella broken in Electron. This was checking that they weren't,
+but they are, so we just disabled the check. YOLO.
 
 diff --git a/src/api/callback.cc b/src/api/callback.cc
 index e6098d5921a038063bf8255f8af6f000becf76a0..3c518870c9c8d92f3dfcd6c270f5e023e3b69633 100644

+ 2 - 0
patches/node/refactor_allow_embedder_overriding_of_internal_fs_calls.patch

@@ -3,6 +3,8 @@ From: Samuel Attard <[email protected]>
 Date: Mon, 22 Apr 2019 13:23:37 -0700
 Subject: refactor: allow embedder overriding of internal FS calls
 
+We use this to allow node's 'fs' module to read from ASAR files as if they were
+a real filesystem.
 
 diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
 index 18acd9d2b64774efdb9261e69923a5ba320a7f0e..0f36697ce5ed0b5bb6df74ceca219574da7eea53 100644

+ 4 - 0
patches/v8/build_gn.patch

@@ -3,6 +3,10 @@ From: Jeremy Apthorp <[email protected]>
 Date: Tue, 16 Apr 2019 10:43:04 -0700
 Subject: build_gn.patch
 
+We force V8 into 'shared library' mode so that it exports its symbols, which is
+necessary for native modules to load.
+
+Also, some fixes relating to mksnapshot on ARM.
 
 diff --git a/BUILD.gn b/BUILD.gn
 index 3a7a9736f8859abc0204f02edca040fda7e22e9d..0264637ec51c26aa924e6809e313678e9b4ac8ea 100644

+ 1 - 0
patches/v8/dcheck.patch

@@ -3,6 +3,7 @@ From: Ales Pergl <[email protected]>
 Date: Mon, 22 Oct 2018 10:47:12 -0700
 Subject: dcheck.patch
 
+https://github.com/auchenberg/volkswagen
 
 diff --git a/src/api/api.cc b/src/api/api.cc
 index d21545a7f1a5ca5f593809d7a6475da20651c116..4d5bcbc1da528ed33f73a88d912ff7d9ea023577 100644

+ 2 - 2
script/lint.js

@@ -184,7 +184,7 @@ const LINTERS = [ {
     let ok = true
     filenames.filter(f => f.endsWith('.patch')).forEach(f => {
       const patchText = fs.readFileSync(f, 'utf8')
-      if (/^Subject: .*$\s+^diff/.test(patchText)) {
+      if (/^Subject: .*$\s+^diff/m.test(patchText)) {
         console.warn(`Patch file '${f}' has no description. Every patch must contain a justification for why the patch exists and the plan for its removal.`)
         ok = false
       }
@@ -246,7 +246,7 @@ async function findFiles (args, linter) {
       return []
     }
   } else if (args.only) {
-    whitelist = new Set(args._)
+    whitelist = new Set(args._.map(p => path.resolve(p)))
   }
 
   // accumulate the raw list of files