mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
957717e483 | ||
|
|
d1ccfea882 | ||
|
|
232ca04edd | ||
|
|
2888e46b7a | ||
|
|
4464a04f35 | ||
|
|
37baff1e31 | ||
|
|
dde19b0583 | ||
|
|
e2b9cd7b7c | ||
|
|
ecd398f8bd | ||
|
|
21f544392b | ||
|
|
5c93682a89 | ||
|
|
1db64c9e51 | ||
|
|
3a747eddbb | ||
|
|
51504aee64 | ||
|
|
360e8a2eb8 |
@@ -423,7 +423,9 @@ step-electron-chromedriver-build: &step-electron-chromedriver-build
|
||||
command: |
|
||||
cd src
|
||||
ninja -C out/Default chrome/test/chromedriver -j $NUMBER_OF_NINJA_PROCESSES
|
||||
electron/script/strip-binaries.py --target-cpu="$TARGET_ARCH" --file $PWD/out/Default/chromedriver
|
||||
if [ "`uname`" == "Linux" ]; then
|
||||
electron/script/strip-binaries.py --target-cpu="$TARGET_ARCH" --file $PWD/out/Default/chromedriver
|
||||
fi
|
||||
ninja -C out/Default electron:electron_chromedriver_zip
|
||||
|
||||
step-electron-chromedriver-store: &step-electron-chromedriver-store
|
||||
@@ -1292,7 +1294,7 @@ steps-test-node: &steps-test-node
|
||||
name: Run Node Tests
|
||||
command: |
|
||||
cd src
|
||||
node electron/script/node-spec-runner.js junit
|
||||
node electron/script/node-spec-runner.js --default --jUnitDir=junit
|
||||
- store_test_results:
|
||||
path: src/junit
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.0.1
|
||||
8.0.2
|
||||
@@ -713,34 +713,34 @@ Clears the recent documents list.
|
||||
|
||||
### `app.setAsDefaultProtocolClient(protocol[, path, args])`
|
||||
|
||||
* `protocol` String - The name of your protocol, without `://`. If you want your
|
||||
app to handle `electron://` links, call this method with `electron` as the
|
||||
parameter.
|
||||
* `path` String (optional) _Windows_ - Defaults to `process.execPath`
|
||||
* `args` String[] (optional) _Windows_ - Defaults to an empty array
|
||||
* `protocol` String - The name of your protocol, without `://`. For example,
|
||||
if you want your app to handle `electron://` links, call this method with
|
||||
`electron` as the parameter.
|
||||
* `path` String (optional) _Windows_ - The path to the Electron executable.
|
||||
Defaults to `process.execPath`
|
||||
* `args` String[] (optional) _Windows_ - Arguments passed to the executable.
|
||||
Defaults to an empty array
|
||||
|
||||
Returns `Boolean` - Whether the call succeeded.
|
||||
|
||||
This method sets the current executable as the default handler for a protocol
|
||||
(aka URI scheme). It allows you to integrate your app deeper into the operating
|
||||
system. Once registered, all links with `your-protocol://` will be opened with
|
||||
the current executable. The whole link, including protocol, will be passed to
|
||||
your application as a parameter.
|
||||
|
||||
On Windows, you can provide optional parameters path, the path to your executable,
|
||||
and args, an array of arguments to be passed to your executable when it launches.
|
||||
Sets the current executable as the default handler for a protocol (aka URI
|
||||
scheme). It allows you to integrate your app deeper into the operating system.
|
||||
Once registered, all links with `your-protocol://` will be opened with the
|
||||
current executable. The whole link, including protocol, will be passed to your
|
||||
application as a parameter.
|
||||
|
||||
**Note:** On macOS, you can only register protocols that have been added to
|
||||
your app's `info.plist`, which can not be modified at runtime. You can however
|
||||
change the file with a simple text editor or script during build time.
|
||||
Please refer to [Apple's documentation][CFBundleURLTypes] for details.
|
||||
your app's `info.plist`, which cannot be modified at runtime. However, you can
|
||||
change the file during build time via [Electron Forge][electron-forge],
|
||||
[Electron Packager][electron-packager], or by editing `info.plist` with a text
|
||||
editor. Please refer to [Apple's documentation][CFBundleURLTypes] for details.
|
||||
|
||||
**Note:** In a Windows Store environment (when packaged as an `appx`) this API
|
||||
will return `true` for all calls but the registry key it sets won't be accessible
|
||||
by other applications. In order to register your Windows Store application
|
||||
as a default protocol handler you must [declare the protocol in your manifest](https://docs.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap-protocol).
|
||||
|
||||
The API uses the Windows Registry and LSSetDefaultHandlerForURLScheme internally.
|
||||
The API uses the Windows Registry and `LSSetDefaultHandlerForURLScheme` internally.
|
||||
|
||||
### `app.removeAsDefaultProtocolClient(protocol[, path, args])` _macOS_ _Windows_
|
||||
|
||||
@@ -759,10 +759,8 @@ protocol (aka URI scheme). If so, it will remove the app as the default handler.
|
||||
* `path` String (optional) _Windows_ - Defaults to `process.execPath`
|
||||
* `args` String[] (optional) _Windows_ - Defaults to an empty array
|
||||
|
||||
Returns `Boolean`
|
||||
|
||||
This method checks if the current executable is the default handler for a protocol
|
||||
(aka URI scheme). If so, it will return true. Otherwise, it will return false.
|
||||
Returns `Boolean` - Whether the current executable is the default handler for a
|
||||
protocol (aka URI scheme).
|
||||
|
||||
**Note:** On macOS, you can use this method to check if the app has been
|
||||
registered as the default protocol handler for a protocol. You can also verify
|
||||
@@ -770,7 +768,7 @@ this by checking `~/Library/Preferences/com.apple.LaunchServices.plist` on the
|
||||
macOS machine. Please refer to
|
||||
[Apple's documentation][LSCopyDefaultHandlerForURLScheme] for details.
|
||||
|
||||
The API uses the Windows Registry and LSCopyDefaultHandlerForURLScheme internally.
|
||||
The API uses the Windows Registry and `LSCopyDefaultHandlerForURLScheme` internally.
|
||||
|
||||
### `app.getApplicationNameForProtocol(url)`
|
||||
|
||||
@@ -1326,6 +1324,8 @@ A `Boolean` property that returns `true` if the app is packaged, `false` otherw
|
||||
[dock-menu]:https://developer.apple.com/macos/human-interface-guidelines/menus/dock-menus/
|
||||
[tasks]:https://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx#tasks
|
||||
[app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx
|
||||
[electron-forge]: https://www.electronforge.io/
|
||||
[electron-packager]: https://github.com/electron/electron-packager
|
||||
[CFBundleURLTypes]: https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-102207-TPXREF115
|
||||
[LSCopyDefaultHandlerForURLScheme]: https://developer.apple.com/library/mac/documentation/Carbon/Reference/LaunchServicesReference/#//apple_ref/c/func/LSCopyDefaultHandlerForURLScheme
|
||||
[handoff]: https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/Handoff/HandoffFundamentals/HandoffFundamentals.html
|
||||
|
||||
@@ -404,8 +404,6 @@ Returns `Boolean` - whether or not this device has the ability to use Touch ID.
|
||||
|
||||
**NOTE:** This API will return `false` on macOS systems older than Sierra 10.12.2.
|
||||
|
||||
**[Deprecated](modernization/property-updates.md)**
|
||||
|
||||
### `systemPreferences.promptTouchID(reason)` _macOS_
|
||||
|
||||
* `reason` String - The reason you are asking for Touch ID authentication
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
const binding = process.electronBinding('crash_reporter')
|
||||
|
||||
class CrashReporter {
|
||||
contructor () {
|
||||
constructor () {
|
||||
this.productName = null
|
||||
this.crashesDirectory = null
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "electron",
|
||||
"version": "8.0.1",
|
||||
"version": "8.0.2",
|
||||
"repository": "https://github.com/electron/electron",
|
||||
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
|
||||
"devDependencies": {
|
||||
|
||||
@@ -34,6 +34,7 @@ scroll_bounce_flag.patch
|
||||
mas-cfisobjc.patch
|
||||
mas-cgdisplayusesforcetogray.patch
|
||||
mas-audiodeviceduck.patch
|
||||
mas_disable_remote_layer.patch
|
||||
mas_disable_remote_accessibility.patch
|
||||
mas_disable_custom_window_frame.patch
|
||||
chrome_key_systems.patch
|
||||
@@ -84,3 +85,5 @@ feat_allow_disbaling_blink_scheduler_throttling_per_renderview.patch
|
||||
accessible_pane_view.patch
|
||||
fix_add_executable_to_chromedriver_s_rpath_for_electron_8.patch
|
||||
fix_use_the_new_mediaplaypause_key_listener_for_internal_chrome.patch
|
||||
fix_route_mouse_event_navigations_through_the_web_contents_delegate.patch
|
||||
feat_add_support_for_overriding_the_base_spellchecker_download_url.patch
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samuel Attard <sattard@slack-corp.com>
|
||||
Date: Tue, 25 Feb 2020 13:28:30 -0800
|
||||
Subject: feat: add support for overriding the base spellchecker download URL
|
||||
|
||||
This patch is required as the testing-only method we were using does not
|
||||
take into account the dictionary name and therefore will not work for
|
||||
production use cases. This is unlikely to be upstreamed as the change
|
||||
is entirely in //chrome.
|
||||
|
||||
diff --git a/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc b/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
|
||||
index 0fb84989f9b2f84ec2a2589dda3d91cf59c0adda..9ff5b33d2885c5532e1496711c27a01c8502725c 100644
|
||||
--- a/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
|
||||
+++ b/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc
|
||||
@@ -48,6 +48,9 @@ namespace {
|
||||
base::LazyInstance<GURL>::Leaky g_download_url_for_testing =
|
||||
LAZY_INSTANCE_INITIALIZER;
|
||||
|
||||
+base::LazyInstance<GURL>::Leaky g_base_download_url_override =
|
||||
+ LAZY_INSTANCE_INITIALIZER;
|
||||
+
|
||||
// Close the file.
|
||||
void CloseDictionary(base::File file) {
|
||||
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
|
||||
@@ -247,6 +250,10 @@ void SpellcheckHunspellDictionary::SetDownloadURLForTesting(const GURL url) {
|
||||
g_download_url_for_testing.Get() = url;
|
||||
}
|
||||
|
||||
+void SpellcheckHunspellDictionary::SetBaseDownloadURL(const GURL url) {
|
||||
+ g_base_download_url_override.Get() = url;
|
||||
+}
|
||||
+
|
||||
GURL SpellcheckHunspellDictionary::GetDictionaryURL() {
|
||||
if (g_download_url_for_testing.Get() != GURL())
|
||||
return g_download_url_for_testing.Get();
|
||||
@@ -254,6 +261,9 @@ GURL SpellcheckHunspellDictionary::GetDictionaryURL() {
|
||||
std::string bdict_file = dictionary_file_.path.BaseName().MaybeAsASCII();
|
||||
DCHECK(!bdict_file.empty());
|
||||
|
||||
+ if (g_base_download_url_override.Get() != GURL())
|
||||
+ return GURL(g_base_download_url_override.Get().spec() + base::ToLowerASCII(bdict_file));
|
||||
+
|
||||
static const char kDownloadServerUrl[] =
|
||||
"https://redirector.gvt1.com/edgedl/chrome/dict/";
|
||||
|
||||
diff --git a/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h b/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h
|
||||
index 4af3201238dfec14bd5a4241b662ca52799e6862..4662bdc08b54304a7f8b2995f60fea9dc5617fff 100644
|
||||
--- a/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h
|
||||
+++ b/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h
|
||||
@@ -85,6 +85,8 @@ class SpellcheckHunspellDictionary
|
||||
// Tests use this method to set a custom URL for downloading dictionaries.
|
||||
static void SetDownloadURLForTesting(const GURL url);
|
||||
|
||||
+ static void SetBaseDownloadURL(const GURL url);
|
||||
+
|
||||
private:
|
||||
// Dictionary download status.
|
||||
enum DownloadStatus {
|
||||
@@ -0,0 +1,34 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samuel Attard <sattard@slack-corp.com>
|
||||
Date: Fri, 14 Feb 2020 13:35:47 -0800
|
||||
Subject: fix: route mouse event navigations through the web_contents delegate
|
||||
|
||||
This ensures that embedders can handle browser-side mouse navigations
|
||||
themselves. We need this so that we can correctly ensure that processes
|
||||
are not restarted for in-document navigations.
|
||||
|
||||
Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1769525
|
||||
|
||||
This patch can be removed once app.allowRendererProcessReuse is forced
|
||||
to true as then Chromiums assumptions around processes become correct.
|
||||
|
||||
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
|
||||
index 70d735dcc38734edaaf6221cd40c49beb6d2e37e..9cd7368966c20b9e9306c41e455c002d686d3013 100644
|
||||
--- a/content/browser/web_contents/web_contents_impl.cc
|
||||
+++ b/content/browser/web_contents/web_contents_impl.cc
|
||||
@@ -2347,11 +2347,13 @@ bool WebContentsImpl::HandleMouseEvent(const blink::WebMouseEvent& event) {
|
||||
WebContentsImpl* outermost = GetOutermostWebContents();
|
||||
if (event.button == blink::WebPointerProperties::Button::kBack &&
|
||||
outermost->controller_.CanGoBack()) {
|
||||
- outermost->controller_.GoBack();
|
||||
+ if (delegate_->OnGoToEntryOffset(-1))
|
||||
+ outermost->controller_.GoBack();
|
||||
return true;
|
||||
} else if (event.button == blink::WebPointerProperties::Button::kForward &&
|
||||
outermost->controller_.CanGoForward()) {
|
||||
- outermost->controller_.GoForward();
|
||||
+ if (delegate_->OnGoToEntryOffset(1))
|
||||
+ outermost->controller_.GoForward();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
126
patches/chromium/mas_disable_remote_layer.patch
Normal file
126
patches/chromium/mas_disable_remote_layer.patch
Normal file
@@ -0,0 +1,126 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Cheng Zhao <zcbenz@gmail.com>
|
||||
Date: Thu, 20 Sep 2018 17:48:49 -0700
|
||||
Subject: mas_disable_remote_layer.patch
|
||||
|
||||
Disable remote layer APIs (CAContext and CALayerHost) for MAS build.
|
||||
|
||||
diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.h b/gpu/ipc/service/image_transport_surface_overlay_mac.h
|
||||
index f343b7e0e04a..d0ecefd4333c 100644
|
||||
--- a/gpu/ipc/service/image_transport_surface_overlay_mac.h
|
||||
+++ b/gpu/ipc/service/image_transport_surface_overlay_mac.h
|
||||
@@ -20,7 +20,9 @@
|
||||
#include "ui/gl/gl_surface_egl.h"
|
||||
#endif
|
||||
|
||||
+#ifndef MAS_BUILD
|
||||
@class CAContext;
|
||||
+#endif
|
||||
@class CALayer;
|
||||
|
||||
namespace ui {
|
||||
@@ -97,7 +99,9 @@ class ImageTransportSurfaceOverlayMacBase : public BaseClass,
|
||||
base::WeakPtr<ImageTransportSurfaceDelegate> delegate_;
|
||||
|
||||
bool use_remote_layer_api_;
|
||||
+#ifndef MAS_BUILD
|
||||
base::scoped_nsobject<CAContext> ca_context_;
|
||||
+#endif
|
||||
std::unique_ptr<ui::CALayerTreeCoordinator> ca_layer_tree_coordinator_;
|
||||
|
||||
gfx::Size pixel_size_;
|
||||
diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.mm b/gpu/ipc/service/image_transport_surface_overlay_mac.mm
|
||||
index 10b345d3727c..b52f03be6351 100644
|
||||
--- a/gpu/ipc/service/image_transport_surface_overlay_mac.mm
|
||||
+++ b/gpu/ipc/service/image_transport_surface_overlay_mac.mm
|
||||
@@ -63,6 +63,7 @@
|
||||
template <typename BaseClass>
|
||||
bool ImageTransportSurfaceOverlayMacBase<BaseClass>::Initialize(
|
||||
gl::GLSurfaceFormat format) {
|
||||
+#ifndef MAS_BUILD
|
||||
// Create the CAContext to send this to the GPU process, and the layer for
|
||||
// the context.
|
||||
if (use_remote_layer_api_) {
|
||||
@@ -71,6 +72,7 @@
|
||||
[CAContext contextWithCGSConnection:connection_id options:@{}] retain]);
|
||||
[ca_context_ setLayer:ca_layer_tree_coordinator_->GetCALayerForDisplay()];
|
||||
}
|
||||
+#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -136,7 +138,9 @@
|
||||
"GLImpl", static_cast<int>(gl::GetGLImplementation()),
|
||||
"width", pixel_size_.width());
|
||||
if (use_remote_layer_api_) {
|
||||
+#ifndef MAS_BUILD
|
||||
params.ca_layer_params.ca_context_id = [ca_context_ contextId];
|
||||
+#endif
|
||||
} else {
|
||||
IOSurfaceRef io_surface =
|
||||
ca_layer_tree_coordinator_->GetIOSurfaceForDisplay();
|
||||
diff --git a/ui/accelerated_widget_mac/display_ca_layer_tree.mm b/ui/accelerated_widget_mac/display_ca_layer_tree.mm
|
||||
index 60abe639bd9c..c38eed5fbdef 100644
|
||||
--- a/ui/accelerated_widget_mac/display_ca_layer_tree.mm
|
||||
+++ b/ui/accelerated_widget_mac/display_ca_layer_tree.mm
|
||||
@@ -98,6 +98,7 @@ - (void)setContentsChanged;
|
||||
}
|
||||
|
||||
void DisplayCALayerTree::GotCALayerFrame(uint32_t ca_context_id) {
|
||||
+#ifndef MAS_BUILD
|
||||
// Early-out if the remote layer has not changed.
|
||||
if ([remote_layer_ contextId] == ca_context_id)
|
||||
return;
|
||||
@@ -122,6 +123,9 @@ - (void)setContentsChanged;
|
||||
[io_surface_layer_ removeFromSuperlayer];
|
||||
io_surface_layer_.reset();
|
||||
}
|
||||
+#else
|
||||
+ NOTREACHED() << "Remote layer is being used in MAS build";
|
||||
+#endif
|
||||
}
|
||||
|
||||
void DisplayCALayerTree::GotIOSurfaceFrame(
|
||||
diff --git a/ui/base/cocoa/remote_layer_api.h b/ui/base/cocoa/remote_layer_api.h
|
||||
index 2057fe69d1bb..2aba330fc488 100644
|
||||
--- a/ui/base/cocoa/remote_layer_api.h
|
||||
+++ b/ui/base/cocoa/remote_layer_api.h
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "ui/base/ui_base_export.h"
|
||||
|
||||
+#ifndef MAS_BUILD
|
||||
// The CGSConnectionID is used to create the CAContext in the process that is
|
||||
// going to share the CALayers that it is rendering to another process to
|
||||
// display.
|
||||
@@ -50,6 +51,8 @@ typedef uint32_t CAContextID;
|
||||
|
||||
#endif // __OBJC__
|
||||
|
||||
+#endif // MAS_BUILD
|
||||
+
|
||||
namespace ui {
|
||||
|
||||
// This function will check if all of the interfaces listed above are supported
|
||||
diff --git a/ui/base/cocoa/remote_layer_api.mm b/ui/base/cocoa/remote_layer_api.mm
|
||||
index bbaf9f466f49..8c846ce9523a 100644
|
||||
--- a/ui/base/cocoa/remote_layer_api.mm
|
||||
+++ b/ui/base/cocoa/remote_layer_api.mm
|
||||
@@ -12,6 +12,7 @@
|
||||
namespace ui {
|
||||
|
||||
bool RemoteLayerAPISupported() {
|
||||
+#ifndef MAS_BUILD
|
||||
static bool disabled_at_command_line =
|
||||
base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kDisableRemoteCoreAnimation);
|
||||
@@ -46,6 +47,9 @@ bool RemoteLayerAPISupported() {
|
||||
|
||||
// If everything is there, we should be able to use the API.
|
||||
return true;
|
||||
+#else
|
||||
+ return false;
|
||||
+#endif // MAS_BUILD
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -120,8 +120,8 @@ def extract_zip(zip_path, destination):
|
||||
def make_zip(zip_file_path, files, dirs):
|
||||
safe_unlink(zip_file_path)
|
||||
if sys.platform == 'darwin':
|
||||
files += dirs
|
||||
execute(['zip', '-r', '-y', zip_file_path] + files)
|
||||
allfiles = files + dirs
|
||||
execute(['zip', '-r', '-y', zip_file_path] + allfiles)
|
||||
else:
|
||||
zip_file = zipfile.ZipFile(zip_file_path, "w", zipfile.ZIP_DEFLATED,
|
||||
allowZip64=True)
|
||||
|
||||
@@ -2,10 +2,16 @@ const cp = require('child_process')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const args = require('minimist')(process.argv.slice(2), {
|
||||
boolean: ['default'],
|
||||
string: ['jUnitDir']
|
||||
})
|
||||
|
||||
const BASE = path.resolve(__dirname, '../..')
|
||||
const DISABLED_TESTS = require('./node-disabled-tests.json')
|
||||
const NODE_DIR = path.resolve(BASE, 'third_party', 'electron_node')
|
||||
const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'
|
||||
const JUNIT_DIR = process.argv[2] ? path.resolve(process.argv[2]) : null
|
||||
const JUNIT_DIR = args.jUnitDir ? path.resolve(args.jUnitDir) : null
|
||||
const TAP_FILE_NAME = 'test.tap'
|
||||
|
||||
const utils = require('./lib/utils')
|
||||
@@ -15,10 +21,43 @@ if (!process.mainModule) {
|
||||
throw new Error('Must call the node spec runner directly')
|
||||
}
|
||||
|
||||
async function main () {
|
||||
const DISABLED_TESTS = require('./node-disabled-tests.json')
|
||||
const defaultOptions = [
|
||||
'tools/test.py',
|
||||
'-p',
|
||||
'tap',
|
||||
'--logfile',
|
||||
TAP_FILE_NAME,
|
||||
'--mode=debug',
|
||||
'default',
|
||||
`--skip-tests=${DISABLED_TESTS.join(',')}`,
|
||||
'--shell',
|
||||
utils.getAbsoluteElectronExec(),
|
||||
'-J'
|
||||
]
|
||||
|
||||
const testChild = cp.spawn('python', ['tools/test.py', '--verbose', '-p', 'tap', '--logfile', TAP_FILE_NAME, '--mode=debug', 'default', `--skip-tests=${DISABLED_TESTS.join(',')}`, '--shell', utils.getAbsoluteElectronExec(), '-J'], {
|
||||
const getCustomOptions = () => {
|
||||
let customOptions = ['tools/test.py']
|
||||
|
||||
// Add all custom arguments.
|
||||
const extra = process.argv.slice(2)
|
||||
if (extra) {
|
||||
customOptions = customOptions.concat(extra)
|
||||
}
|
||||
|
||||
// We need this unilaterally or Node.js will try
|
||||
// to run from out/Release/node.
|
||||
customOptions = customOptions.concat([
|
||||
'--shell',
|
||||
utils.getAbsoluteElectronExec()
|
||||
])
|
||||
|
||||
return customOptions
|
||||
}
|
||||
|
||||
async function main () {
|
||||
const options = args.default ? defaultOptions : getCustomOptions()
|
||||
|
||||
const testChild = cp.spawn('python', options, {
|
||||
env: {
|
||||
...process.env,
|
||||
ELECTRON_RUN_AS_NODE: 'true'
|
||||
|
||||
@@ -18,7 +18,7 @@ const CHECK_INTERVAL = 5000
|
||||
|
||||
const CACHE_DIR = path.resolve(__dirname, '.cache')
|
||||
const NO_NOTES = 'No notes'
|
||||
const FOLLOW_REPOS = [ 'electron/electron', 'electron/libchromiumcontent', 'electron/node' ]
|
||||
const FOLLOW_REPOS = [ 'electron/electron', 'electron/node' ]
|
||||
|
||||
const breakTypes = new Set(['breaking-change'])
|
||||
const docTypes = new Set(['doc', 'docs'])
|
||||
@@ -341,44 +341,6 @@ const addRepoToPool = async (pool, repo, from, to) => {
|
||||
**** Other Repos
|
||||
***/
|
||||
|
||||
// other repos - gyp
|
||||
|
||||
const getGypSubmoduleRef = async (dir, point) => {
|
||||
// example: '160000 commit 028b0af83076cec898f4ebce208b7fadb715656e libchromiumcontent'
|
||||
const response = await runGit(
|
||||
path.dirname(dir),
|
||||
['ls-tree', '-t', point, path.basename(dir)]
|
||||
)
|
||||
|
||||
const line = response.split('\n').filter(line => line.startsWith('160000')).shift()
|
||||
const tokens = line ? line.split(/\s/).map(token => token.trim()) : null
|
||||
const ref = tokens && tokens.length >= 3 ? tokens[2] : null
|
||||
|
||||
return ref
|
||||
}
|
||||
|
||||
const getDependencyCommitsGyp = async (pool, fromRef, toRef) => {
|
||||
const commits = []
|
||||
|
||||
const repos = [{
|
||||
owner: 'electron',
|
||||
repo: 'libchromiumcontent',
|
||||
dir: path.resolve(ELECTRON_VERSION, 'vendor', 'libchromiumcontent')
|
||||
}, {
|
||||
owner: 'electron',
|
||||
repo: 'node',
|
||||
dir: path.resolve(ELECTRON_VERSION, 'vendor', 'node')
|
||||
}]
|
||||
|
||||
for (const repo of repos) {
|
||||
const from = await getGypSubmoduleRef(repo.dir, fromRef)
|
||||
const to = await getGypSubmoduleRef(repo.dir, toRef)
|
||||
await addRepoToPool(pool, repo, from, to)
|
||||
}
|
||||
|
||||
return commits
|
||||
}
|
||||
|
||||
// other repos - gn
|
||||
|
||||
const getDepsVariable = async (ref, key) => {
|
||||
@@ -416,17 +378,6 @@ const getDependencyCommitsGN = async (pool, fromRef, toRef) => {
|
||||
}
|
||||
}
|
||||
|
||||
// other repos - controller
|
||||
|
||||
const getDependencyCommits = async (pool, from, to) => {
|
||||
const filename = path.resolve(ELECTRON_VERSION, 'vendor', 'libchromiumcontent')
|
||||
const useGyp = fs.existsSync(filename)
|
||||
|
||||
return useGyp
|
||||
? getDependencyCommitsGyp(pool, from, to)
|
||||
: getDependencyCommitsGN(pool, from, to)
|
||||
}
|
||||
|
||||
// Changes are interesting if they make a change relative to a previous
|
||||
// release in the same series. For example if you fix a Y.0.0 bug, that
|
||||
// should be included in the Y.0.1 notes even if it's also tropped back
|
||||
@@ -474,7 +425,7 @@ const getNotes = async (fromRef, toRef, newVersion) => {
|
||||
semver.major(fromRef) === semver.major(toRef)
|
||||
|
||||
if (includeDeps) {
|
||||
await getDependencyCommits(pool, fromRef, toRef)
|
||||
await getDependencyCommitsGN(pool, fromRef, toRef)
|
||||
}
|
||||
|
||||
// remove any old commits
|
||||
|
||||
@@ -22,7 +22,7 @@ def strip_binary(binary_path, target_cpu):
|
||||
strip = 'mips64el-redhat-linux-strip'
|
||||
else:
|
||||
strip = 'strip'
|
||||
execute([strip, binary_path])
|
||||
execute([strip, '--preserve-dates', binary_path])
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
|
||||
@@ -213,6 +213,21 @@ bool ElectronMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
<< " is not supported. See https://crbug.com/638180.";
|
||||
#endif
|
||||
|
||||
#if defined(MAS_BUILD)
|
||||
// In MAS build we are using --disable-remote-core-animation.
|
||||
//
|
||||
// According to ccameron:
|
||||
// If you're running with --disable-remote-core-animation, you may want to
|
||||
// also run with --disable-gpu-memory-buffer-compositor-resources as well.
|
||||
// That flag makes it so we use regular GL textures instead of IOSurfaces
|
||||
// for compositor resources. IOSurfaces are very heavyweight to
|
||||
// create/destroy, but they can be displayed directly by CoreAnimation (and
|
||||
// --disable-remote-core-animation makes it so we don't use this property,
|
||||
// so they're just heavyweight with no upside).
|
||||
command_line->AppendSwitch(
|
||||
::switches::kDisableGpuMemoryBufferCompositorResources);
|
||||
#endif
|
||||
|
||||
content_client_ = std::make_unique<ElectronContentClient>();
|
||||
SetContentClient(content_client_.get());
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ void ElectronMainDelegate::SetUpBundleOverrides() {
|
||||
|
||||
void RegisterAtomCrApp() {
|
||||
// Force the NSApplication subclass to be used.
|
||||
[ElectronApplication sharedApplication];
|
||||
[AtomApplication sharedApplication];
|
||||
}
|
||||
|
||||
} // namespace electron
|
||||
|
||||
@@ -713,7 +713,7 @@ void SetSpellCheckerDictionaryDownloadURL(gin_helper::ErrorThrower thrower,
|
||||
"valid URL");
|
||||
return;
|
||||
}
|
||||
SpellcheckHunspellDictionary::SetDownloadURLForTesting(url);
|
||||
SpellcheckHunspellDictionary::SetBaseDownloadURL(url);
|
||||
}
|
||||
|
||||
bool Session::AddWordToSpellCheckerDictionary(const std::string& word) {
|
||||
|
||||
@@ -28,20 +28,19 @@
|
||||
namespace electron {
|
||||
|
||||
void Browser::SetShutdownHandler(base::Callback<bool()> handler) {
|
||||
[[ElectronApplication sharedApplication]
|
||||
setShutdownHandler:std::move(handler)];
|
||||
[[AtomApplication sharedApplication] setShutdownHandler:std::move(handler)];
|
||||
}
|
||||
|
||||
void Browser::Focus() {
|
||||
[[ElectronApplication sharedApplication] activateIgnoringOtherApps:NO];
|
||||
[[AtomApplication sharedApplication] activateIgnoringOtherApps:NO];
|
||||
}
|
||||
|
||||
void Browser::Hide() {
|
||||
[[ElectronApplication sharedApplication] hide:nil];
|
||||
[[AtomApplication sharedApplication] hide:nil];
|
||||
}
|
||||
|
||||
void Browser::Show() {
|
||||
[[ElectronApplication sharedApplication] unhide:nil];
|
||||
[[AtomApplication sharedApplication] unhide:nil];
|
||||
}
|
||||
|
||||
void Browser::AddRecentDocument(const base::FilePath& path) {
|
||||
@@ -162,7 +161,7 @@ void Browser::SetUserActivity(const std::string& type,
|
||||
std::string url_string;
|
||||
args->GetNext(&url_string);
|
||||
|
||||
[[ElectronApplication sharedApplication]
|
||||
[[AtomApplication sharedApplication]
|
||||
setCurrentActivity:base::SysUTF8ToNSString(type)
|
||||
withUserInfo:DictionaryValueToNSDictionary(user_info)
|
||||
withWebpageURL:net::NSURLWithGURL(GURL(url_string))];
|
||||
@@ -170,21 +169,21 @@ void Browser::SetUserActivity(const std::string& type,
|
||||
|
||||
std::string Browser::GetCurrentActivityType() {
|
||||
NSUserActivity* userActivity =
|
||||
[[ElectronApplication sharedApplication] getCurrentActivity];
|
||||
[[AtomApplication sharedApplication] getCurrentActivity];
|
||||
return base::SysNSStringToUTF8(userActivity.activityType);
|
||||
}
|
||||
|
||||
void Browser::InvalidateCurrentActivity() {
|
||||
[[ElectronApplication sharedApplication] invalidateCurrentActivity];
|
||||
[[AtomApplication sharedApplication] invalidateCurrentActivity];
|
||||
}
|
||||
|
||||
void Browser::ResignCurrentActivity() {
|
||||
[[ElectronApplication sharedApplication] resignCurrentActivity];
|
||||
[[AtomApplication sharedApplication] resignCurrentActivity];
|
||||
}
|
||||
|
||||
void Browser::UpdateCurrentActivity(const std::string& type,
|
||||
const base::DictionaryValue& user_info) {
|
||||
[[ElectronApplication sharedApplication]
|
||||
[[AtomApplication sharedApplication]
|
||||
updateCurrentActivity:base::SysUTF8ToNSString(type)
|
||||
withUserInfo:DictionaryValueToNSDictionary(user_info)];
|
||||
}
|
||||
@@ -290,17 +289,16 @@ std::string Browser::GetExecutableFileProductName() const {
|
||||
}
|
||||
|
||||
int Browser::DockBounce(BounceType type) {
|
||||
return [[ElectronApplication sharedApplication]
|
||||
return [[AtomApplication sharedApplication]
|
||||
requestUserAttention:static_cast<NSRequestUserAttentionType>(type)];
|
||||
}
|
||||
|
||||
void Browser::DockCancelBounce(int request_id) {
|
||||
[[ElectronApplication sharedApplication]
|
||||
cancelUserAttentionRequest:request_id];
|
||||
[[AtomApplication sharedApplication] cancelUserAttentionRequest:request_id];
|
||||
}
|
||||
|
||||
void Browser::DockSetBadgeText(const std::string& label) {
|
||||
NSDockTile* tile = [[ElectronApplication sharedApplication] dockTile];
|
||||
NSDockTile* tile = [[AtomApplication sharedApplication] dockTile];
|
||||
[tile setBadgeLabel:base::SysUTF8ToNSString(label)];
|
||||
}
|
||||
|
||||
@@ -311,7 +309,7 @@ void Browser::DockDownloadFinished(const std::string& filePath) {
|
||||
}
|
||||
|
||||
std::string Browser::DockGetBadgeText() {
|
||||
NSDockTile* tile = [[ElectronApplication sharedApplication] dockTile];
|
||||
NSDockTile* tile = [[AtomApplication sharedApplication] dockTile];
|
||||
return base::SysNSStringToUTF8([tile badgeLabel]);
|
||||
}
|
||||
|
||||
@@ -370,7 +368,7 @@ void Browser::DockSetMenu(ElectronMenuModel* model) {
|
||||
}
|
||||
|
||||
void Browser::DockSetIcon(const gfx::Image& image) {
|
||||
[[ElectronApplication sharedApplication]
|
||||
[[AtomApplication sharedApplication]
|
||||
setApplicationIconImage:image.AsNSImage()];
|
||||
}
|
||||
|
||||
@@ -393,7 +391,7 @@ void Browser::ShowAboutPanel() {
|
||||
options = [NSDictionary dictionaryWithDictionary:mutable_options];
|
||||
}
|
||||
|
||||
[[ElectronApplication sharedApplication]
|
||||
[[AtomApplication sharedApplication]
|
||||
orderFrontStandardAboutPanelWithOptions:options];
|
||||
}
|
||||
|
||||
@@ -411,7 +409,7 @@ void Browser::SetAboutPanelOptions(const base::DictionaryValue& options) {
|
||||
}
|
||||
|
||||
void Browser::ShowEmojiPanel() {
|
||||
[[ElectronApplication sharedApplication] orderFrontCharacterPalette:nil];
|
||||
[[AtomApplication sharedApplication] orderFrontCharacterPalette:nil];
|
||||
}
|
||||
|
||||
bool Browser::IsEmojiPanelSupported() {
|
||||
|
||||
@@ -282,8 +282,21 @@ content::WebContents* CommonWebContentsDelegate::OpenURLFromTab(
|
||||
load_url_params.should_replace_current_entry =
|
||||
params.should_replace_current_entry;
|
||||
load_url_params.is_renderer_initiated = params.is_renderer_initiated;
|
||||
load_url_params.started_from_context_menu = params.started_from_context_menu;
|
||||
load_url_params.initiator_origin = params.initiator_origin;
|
||||
load_url_params.should_clear_history_list = true;
|
||||
load_url_params.source_site_instance = params.source_site_instance;
|
||||
load_url_params.frame_tree_node_id = params.frame_tree_node_id;
|
||||
load_url_params.redirect_chain = params.redirect_chain;
|
||||
load_url_params.has_user_gesture = params.user_gesture;
|
||||
load_url_params.blob_url_loader_factory = params.blob_url_loader_factory;
|
||||
load_url_params.href_translate = params.href_translate;
|
||||
load_url_params.reload_type = params.reload_type;
|
||||
|
||||
if (params.post_data) {
|
||||
load_url_params.load_type =
|
||||
content::NavigationController::LOAD_TYPE_HTTP_POST;
|
||||
load_url_params.post_data = params.post_data;
|
||||
}
|
||||
|
||||
source->GetController().LoadURLWithParams(load_url_params);
|
||||
return source;
|
||||
|
||||
@@ -35,7 +35,7 @@ void ElectronBrowserMainParts::FreeAppDelegate() {
|
||||
}
|
||||
|
||||
void ElectronBrowserMainParts::RegisterURLHandler() {
|
||||
[[ElectronApplication sharedApplication] registerURLHandler];
|
||||
[[AtomApplication sharedApplication] registerURLHandler];
|
||||
}
|
||||
|
||||
// Replicates NSApplicationMain, but doesn't start a run loop.
|
||||
|
||||
@@ -93,6 +93,7 @@ void ElectronJavaScriptDialogManager::RunJavaScriptDialog(
|
||||
|
||||
electron::MessageBoxSettings settings;
|
||||
settings.parent_window = window;
|
||||
settings.checkbox_label = checkbox;
|
||||
settings.buttons = buttons;
|
||||
settings.default_id = default_id;
|
||||
settings.cancel_id = cancel_id;
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <LocalAuthentication/LocalAuthentication.h>
|
||||
|
||||
@interface ElectronApplication : NSApplication <CrAppProtocol,
|
||||
CrAppControlProtocol,
|
||||
NSUserActivityDelegate> {
|
||||
@interface AtomApplication : NSApplication <CrAppProtocol,
|
||||
CrAppControlProtocol,
|
||||
NSUserActivityDelegate> {
|
||||
@private
|
||||
BOOL handlingSendEvent_;
|
||||
base::scoped_nsobject<NSUserActivity> currentActivity_;
|
||||
@@ -20,7 +20,7 @@
|
||||
base::Callback<bool()> shouldShutdown_;
|
||||
}
|
||||
|
||||
+ (ElectronApplication*)sharedApplication;
|
||||
+ (AtomApplication*)sharedApplication;
|
||||
|
||||
- (void)setShutdownHandler:(base::Callback<bool()>)handler;
|
||||
- (void)registerURLHandler;
|
||||
|
||||
@@ -29,16 +29,16 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
||||
|
||||
} // namespace
|
||||
|
||||
@interface ElectronApplication () <NativeEventProcessor> {
|
||||
@interface AtomApplication () <NativeEventProcessor> {
|
||||
base::ObserverList<content::NativeEventProcessorObserver>::Unchecked
|
||||
observers_;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation ElectronApplication
|
||||
@implementation AtomApplication
|
||||
|
||||
+ (ElectronApplication*)sharedApplication {
|
||||
return (ElectronApplication*)[super sharedApplication];
|
||||
+ (AtomApplication*)sharedApplication {
|
||||
return (AtomApplication*)[super sharedApplication];
|
||||
}
|
||||
|
||||
- (void)terminate:(id)sender {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>ElectronApplication</string>
|
||||
<string>AtomApplication</string>
|
||||
<key>NSSupportsAutomaticGraphicsSwitching</key>
|
||||
<true/>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
|
||||
@@ -50,8 +50,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 8,0,1,0
|
||||
PRODUCTVERSION 8,0,1,0
|
||||
FILEVERSION 8,0,2,0
|
||||
PRODUCTVERSION 8,0,2,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -68,12 +68,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "GitHub, Inc."
|
||||
VALUE "FileDescription", "Electron"
|
||||
VALUE "FileVersion", "8.0.1"
|
||||
VALUE "FileVersion", "8.0.2"
|
||||
VALUE "InternalName", "electron.exe"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
|
||||
VALUE "OriginalFilename", "electron.exe"
|
||||
VALUE "ProductName", "Electron"
|
||||
VALUE "ProductVersion", "8.0.1"
|
||||
VALUE "ProductVersion", "8.0.2"
|
||||
VALUE "SquirrelAwareVersion", "1"
|
||||
END
|
||||
END
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</object>
|
||||
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1048">
|
||||
<object class="NSCustomObject" id="1021">
|
||||
<string key="NSClassName">ElectronApplication</string>
|
||||
<string key="NSClassName">AtomApplication</string>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="1014">
|
||||
<string key="NSClassName">FirstResponder</string>
|
||||
|
||||
@@ -296,4 +296,12 @@ void ElectronSandboxedRendererClient::WillReleaseScriptContext(
|
||||
InvokeHiddenCallback(context, kLifecycleKey, "onExit");
|
||||
}
|
||||
|
||||
bool ElectronSandboxedRendererClient::ShouldFork(blink::WebLocalFrame* frame,
|
||||
const GURL& url,
|
||||
const std::string& http_method,
|
||||
bool is_initial_navigation,
|
||||
bool is_server_redirect) {
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace electron
|
||||
|
||||
@@ -37,6 +37,11 @@ class ElectronSandboxedRendererClient : public RendererClientBase {
|
||||
void RenderViewCreated(content::RenderView*) override;
|
||||
void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override;
|
||||
void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override;
|
||||
bool ShouldFork(blink::WebLocalFrame* frame,
|
||||
const GURL& url,
|
||||
const std::string& http_method,
|
||||
bool is_initial_navigation,
|
||||
bool is_server_redirect) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<base::ProcessMetrics> metrics_;
|
||||
|
||||
@@ -419,110 +419,168 @@ describe('BrowserWindow module', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('navigation events', () => {
|
||||
let w = null as unknown as BrowserWindow
|
||||
beforeEach(() => {
|
||||
w = new BrowserWindow({show: false, webPreferences: {nodeIntegration: true}})
|
||||
})
|
||||
afterEach(async () => {
|
||||
await closeWindow(w)
|
||||
w = null as unknown as BrowserWindow
|
||||
})
|
||||
for (const sandbox of [false, true]) {
|
||||
describe(`navigation events${sandbox ? ' with sandbox' : ''}`, () => {
|
||||
let w = null as unknown as BrowserWindow
|
||||
beforeEach(() => {
|
||||
w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: false, sandbox } })
|
||||
})
|
||||
afterEach(async () => {
|
||||
await closeWindow(w)
|
||||
w = null as unknown as BrowserWindow
|
||||
})
|
||||
|
||||
describe('will-navigate event', () => {
|
||||
it('allows the window to be closed from the event listener', (done) => {
|
||||
w.webContents.once('will-navigate', () => {
|
||||
w.close()
|
||||
done()
|
||||
describe('will-navigate event', () => {
|
||||
let server = null as unknown as http.Server
|
||||
let url = null as unknown as string
|
||||
before((done) => {
|
||||
server = http.createServer((req, res) => { res.end('') })
|
||||
server.listen(0, '127.0.0.1', () => {
|
||||
url = `http://127.0.0.1:${(server.address() as AddressInfo).port}/`
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
after(() => {
|
||||
server.close()
|
||||
})
|
||||
|
||||
it('allows the window to be closed from the event listener', (done) => {
|
||||
w.webContents.once('will-navigate', () => {
|
||||
w.close()
|
||||
done()
|
||||
})
|
||||
w.loadFile(path.join(fixtures, 'pages', 'will-navigate.html'))
|
||||
})
|
||||
|
||||
it('can be prevented', (done) => {
|
||||
let willNavigate = false
|
||||
w.webContents.once('will-navigate', (e) => {
|
||||
willNavigate = true
|
||||
e.preventDefault()
|
||||
})
|
||||
w.webContents.on('did-stop-loading', () => {
|
||||
if (willNavigate) {
|
||||
// i.e. it shouldn't have had '?navigated' appended to it.
|
||||
expect(w.webContents.getURL().endsWith('will-navigate.html')).to.be.true()
|
||||
done()
|
||||
}
|
||||
})
|
||||
w.loadFile(path.join(fixtures, 'pages', 'will-navigate.html'))
|
||||
})
|
||||
|
||||
it('is triggered when navigating from file: to http:', async () => {
|
||||
await w.loadFile(path.join(fixtures, 'api', 'blank.html'))
|
||||
w.webContents.executeJavaScript(`location.href = ${JSON.stringify(url)}`)
|
||||
const navigatedTo = await new Promise(resolve => {
|
||||
w.webContents.once('will-navigate', (e, url) => {
|
||||
e.preventDefault()
|
||||
resolve(url)
|
||||
})
|
||||
})
|
||||
expect(navigatedTo).to.equal(url)
|
||||
expect(w.webContents.getURL()).to.match(/^file:/)
|
||||
})
|
||||
|
||||
it('is triggered when navigating from about:blank to http:', async () => {
|
||||
await w.loadURL('about:blank')
|
||||
w.webContents.executeJavaScript(`location.href = ${JSON.stringify(url)}`)
|
||||
const navigatedTo = await new Promise(resolve => {
|
||||
w.webContents.once('will-navigate', (e, url) => {
|
||||
e.preventDefault()
|
||||
resolve(url)
|
||||
})
|
||||
})
|
||||
expect(navigatedTo).to.equal(url)
|
||||
expect(w.webContents.getURL()).to.equal('about:blank')
|
||||
})
|
||||
})
|
||||
|
||||
describe('will-redirect event', () => {
|
||||
let server = null as unknown as http.Server
|
||||
let url = null as unknown as string
|
||||
before((done) => {
|
||||
server = http.createServer((req, res) => {
|
||||
if (req.url === '/302') {
|
||||
res.setHeader('Location', '/200')
|
||||
res.statusCode = 302
|
||||
res.end()
|
||||
} else if (req.url === '/navigate-302') {
|
||||
res.end(`<html><body><script>window.location='${url}/302'</script></body></html>`)
|
||||
} else {
|
||||
res.end()
|
||||
}
|
||||
})
|
||||
server.listen(0, '127.0.0.1', () => {
|
||||
url = `http://127.0.0.1:${(server.address() as AddressInfo).port}`
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
after(() => {
|
||||
server.close()
|
||||
})
|
||||
it('is emitted on redirects', (done) => {
|
||||
w.webContents.on('will-redirect', () => {
|
||||
done()
|
||||
})
|
||||
w.loadURL(`${url}/302`)
|
||||
})
|
||||
|
||||
it('is emitted after will-navigate on redirects', (done) => {
|
||||
let navigateCalled = false
|
||||
w.webContents.on('will-navigate', () => {
|
||||
navigateCalled = true
|
||||
})
|
||||
w.webContents.on('will-redirect', () => {
|
||||
expect(navigateCalled).to.equal(true, 'should have called will-navigate first')
|
||||
done()
|
||||
})
|
||||
w.loadURL(`${url}/navigate-302`)
|
||||
})
|
||||
|
||||
it('is emitted before did-stop-loading on redirects', (done) => {
|
||||
let stopCalled = false
|
||||
w.webContents.on('did-stop-loading', () => {
|
||||
stopCalled = true
|
||||
})
|
||||
w.webContents.on('will-redirect', () => {
|
||||
expect(stopCalled).to.equal(false, 'should not have called did-stop-loading first')
|
||||
done()
|
||||
})
|
||||
w.loadURL(`${url}/302`)
|
||||
})
|
||||
|
||||
it('allows the window to be closed from the event listener', (done) => {
|
||||
w.webContents.once('will-redirect', () => {
|
||||
w.close()
|
||||
done()
|
||||
})
|
||||
w.loadURL(`${url}/302`)
|
||||
})
|
||||
|
||||
it('can be prevented', (done) => {
|
||||
w.webContents.once('will-redirect', (event) => {
|
||||
event.preventDefault()
|
||||
})
|
||||
w.webContents.on('will-navigate', (e, u) => {
|
||||
expect(u).to.equal(`${url}/302`)
|
||||
})
|
||||
w.webContents.on('did-stop-loading', () => {
|
||||
expect(w.webContents.getURL()).to.equal(
|
||||
`${url}/navigate-302`,
|
||||
'url should not have changed after navigation event'
|
||||
)
|
||||
done()
|
||||
})
|
||||
w.webContents.on('will-redirect', (e, u) => {
|
||||
expect(u).to.equal(`${url}/200`)
|
||||
})
|
||||
w.loadURL(`${url}/navigate-302`)
|
||||
})
|
||||
w.loadFile(path.join(fixtures, 'pages', 'will-navigate.html'))
|
||||
})
|
||||
})
|
||||
|
||||
describe('will-redirect event', () => {
|
||||
let server = null as unknown as http.Server
|
||||
let url = null as unknown as string
|
||||
before((done) => {
|
||||
server = http.createServer((req, res) => {
|
||||
if (req.url === '/302') {
|
||||
res.setHeader('Location', '/200')
|
||||
res.statusCode = 302
|
||||
res.end()
|
||||
} else if (req.url === '/navigate-302') {
|
||||
res.end(`<html><body><script>window.location='${url}/302'</script></body></html>`)
|
||||
} else {
|
||||
res.end()
|
||||
}
|
||||
})
|
||||
server.listen(0, '127.0.0.1', () => {
|
||||
url = `http://127.0.0.1:${(server.address() as AddressInfo).port}`
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
after(() => {
|
||||
server.close()
|
||||
})
|
||||
it('is emitted on redirects', (done) => {
|
||||
w.webContents.on('will-redirect', (event, url) => {
|
||||
done()
|
||||
})
|
||||
w.loadURL(`${url}/302`)
|
||||
})
|
||||
|
||||
it('is emitted after will-navigate on redirects', (done) => {
|
||||
let navigateCalled = false
|
||||
w.webContents.on('will-navigate', () => {
|
||||
navigateCalled = true
|
||||
})
|
||||
w.webContents.on('will-redirect', (event, url) => {
|
||||
expect(navigateCalled).to.equal(true, 'should have called will-navigate first')
|
||||
done()
|
||||
})
|
||||
w.loadURL(`${url}/navigate-302`)
|
||||
})
|
||||
|
||||
it('is emitted before did-stop-loading on redirects', (done) => {
|
||||
let stopCalled = false
|
||||
w.webContents.on('did-stop-loading', () => {
|
||||
stopCalled = true
|
||||
})
|
||||
w.webContents.on('will-redirect', (event, url) => {
|
||||
expect(stopCalled).to.equal(false, 'should not have called did-stop-loading first')
|
||||
done()
|
||||
})
|
||||
w.loadURL(`${url}/302`)
|
||||
})
|
||||
|
||||
it('allows the window to be closed from the event listener', (done) => {
|
||||
w.webContents.once('will-redirect', (event, input) => {
|
||||
w.close()
|
||||
done()
|
||||
})
|
||||
w.loadURL(`${url}/302`)
|
||||
})
|
||||
|
||||
it('can be prevented', (done) => {
|
||||
w.webContents.once('will-redirect', (event) => {
|
||||
event.preventDefault()
|
||||
})
|
||||
w.webContents.on('will-navigate', (e, u) => {
|
||||
expect(u).to.equal(`${url}/302`)
|
||||
})
|
||||
w.webContents.on('did-stop-loading', () => {
|
||||
expect(w.webContents.getURL()).to.equal(
|
||||
`${url}/navigate-302`,
|
||||
'url should not have changed after navigation event'
|
||||
)
|
||||
done()
|
||||
})
|
||||
w.webContents.on('will-redirect', (e, u) => {
|
||||
expect(u).to.equal(`${url}/200`)
|
||||
})
|
||||
w.loadURL(`${url}/navigate-302`)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
describe('focus and visibility', () => {
|
||||
let w = null as unknown as BrowserWindow
|
||||
@@ -2039,8 +2097,7 @@ describe('BrowserWindow module', () => {
|
||||
'did-finish-load',
|
||||
'did-frame-finish-load',
|
||||
'did-navigate-in-page',
|
||||
// TODO(nornagon): sandboxed pages should also emit will-navigate
|
||||
// 'will-navigate',
|
||||
'will-navigate',
|
||||
'did-start-loading',
|
||||
'did-stop-loading',
|
||||
'did-frame-finish-load',
|
||||
|
||||
2
spec/fixtures/pages/will-navigate.html
vendored
2
spec/fixtures/pages/will-navigate.html
vendored
@@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
location.reload();
|
||||
location.href += '?navigated'
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user