This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
/
dbc6c805b7430f401875d50b8566d9f743ca402b.diff
447 lines (425 loc) · 16.7 KB
/
dbc6c805b7430f401875d50b8566d9f743ca402b.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
diff --git a/chrome/browser/download/download_request_limiter.cc b/chrome/browser/download/download_request_limiter.cc
index 75cb0faf7e20..ae816a21408d 100644
--- a/chrome/browser/download/download_request_limiter.cc
+++ b/chrome/browser/download/download_request_limiter.cc
@@ -103,7 +103,7 @@ DownloadRequestLimiter::TabDownloadState::TabDownloadState(
: content::WebContentsObserver(contents),
web_contents_(contents),
host_(host),
- status_(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD),
+ status_(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED),
ui_status_(DownloadRequestLimiter::DOWNLOAD_UI_DEFAULT),
download_count_(0),
download_seen_(false),
@@ -278,7 +278,7 @@ void DownloadRequestLimiter::TabDownloadState::Accept() {
DownloadRequestLimiter::TabDownloadState::TabDownloadState()
: web_contents_(nullptr),
host_(nullptr),
- status_(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD),
+ status_(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED),
ui_status_(DownloadRequestLimiter::DOWNLOAD_UI_DEFAULT),
download_count_(0),
download_seen_(false),
diff --git a/content/browser/frame_host/ancestor_throttle.cc b/content/browser/frame_host/ancestor_throttle.cc
index 2045100270c2..2e02f31dd7f3 100644
--- a/content/browser/frame_host/ancestor_throttle.cc
+++ b/content/browser/frame_host/ancestor_throttle.cc
@@ -263,6 +263,7 @@ void AncestorThrottle::ConsoleError(HeaderDisposition disposition) {
AncestorThrottle::HeaderDisposition AncestorThrottle::ParseHeader(
const net::HttpResponseHeaders* headers,
std::string* header_value) {
+ return HeaderDisposition::ALLOWALL;
DCHECK(header_value);
if (!headers)
return HeaderDisposition::NONE;
diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc
index 06df9bd3e545..9ae377f9b4ab 100644
--- a/net/url_request/url_request_job.cc
+++ b/net/url_request/url_request_job.cc
@@ -207,7 +207,8 @@ bool URLRequestJob::IsRedirectResponse(GURL* location,
}
}
*http_status_code = headers->response_code();
- return true;
+
+ return false;
}
bool URLRequestJob::CopyFragmentOnRedirect(const GURL& location) const {
diff --git a/third_party/blink/renderer/core/dom/BUILD.gn b/third_party/blink/renderer/core/dom/BUILD.gn
index 9557a946f0d3..e6be6871b5c0 100644
--- a/third_party/blink/renderer/core/dom/BUILD.gn
+++ b/third_party/blink/renderer/core/dom/BUILD.gn
@@ -88,6 +88,10 @@ blink_core_sources("dom") {
"dom_time_stamp.h",
"dom_token_list.cc",
"dom_token_list.h",
+ "dynamic_node_list.h",
+ "dynamic_node_list.cc",
+ "events/event_node_collection.h",
+ "events/event_node_collection.cc",
"element.cc",
"element.h",
"element_data.cc",
diff --git a/third_party/blink/renderer/core/dom/dynamic_node_list.cc b/third_party/blink/renderer/core/dom/dynamic_node_list.cc
new file mode 100644
index 000000000000..2fcb5de5fe35
--- /dev/null
+++ b/third_party/blink/renderer/core/dom/dynamic_node_list.cc
@@ -0,0 +1,23 @@
+#include "third_party/blink/renderer/core/dom/dynamic_node_list.h"
+
+namespace blink {
+
+ unsigned DynamicNodeList::length() const {
+ return nodes_.size();
+ }
+
+ void DynamicNodeList::Trace(Visitor* visitor) {
+ visitor->Trace(nodes_);
+ NodeList::Trace(visitor);
+ }
+
+
+ Node* DynamicNodeList::item(unsigned i) const {
+ return nodes_[i].Get();
+ }
+
+ void DynamicNodeList::AddNode(Node* node) {
+ nodes_.push_back(node);
+ }
+
+} // namespace blink
diff --git a/third_party/blink/renderer/core/dom/dynamic_node_list.h b/third_party/blink/renderer/core/dom/dynamic_node_list.h
new file mode 100644
index 000000000000..716d0261dcd6
--- /dev/null
+++ b/third_party/blink/renderer/core/dom/dynamic_node_list.h
@@ -0,0 +1,31 @@
+#ifndef DynamicNodeList_h
+#define DynamicNodeList_h
+
+#include "third_party/blink/renderer/core/dom/node_list.h"
+#include "third_party/blink/renderer/core/dom/node.h"
+
+namespace blink {
+
+class DynamicNodeList : public NodeList {
+ public:
+
+ DynamicNodeList() {}
+ ~DynamicNodeList() override {}
+
+ void Trace(Visitor*) override;
+
+ bool IsEmptyNodeList() const override { return length() == 0; }
+
+ unsigned length() const override;
+ Node* item(unsigned) const override;
+ void AddNode(Node* node);
+
+ private:
+ Node* VirtualOwnerNode() const override { return nullptr; }
+
+ mutable HeapVector<Member<Node>> nodes_;
+};
+
+} // namespace blink
+
+#endif // DynamicNodeList_h
diff --git a/third_party/blink/renderer/core/dom/events/event_node_collection.cc b/third_party/blink/renderer/core/dom/events/event_node_collection.cc
new file mode 100644
index 000000000000..0593864be7eb
--- /dev/null
+++ b/third_party/blink/renderer/core/dom/events/event_node_collection.cc
@@ -0,0 +1,26 @@
+#include "third_party/blink/renderer/core/dom/events/event_node_collection.h"
+
+namespace blink {
+
+ EventNodeCollection::EventNodeCollection() {
+ node_list_ = MakeGarbageCollected<DynamicNodeList>();
+ name_list_ = MakeGarbageCollected<DOMStringList>();
+ count_ = 0;
+ }
+
+ void EventNodeCollection::Trace(Visitor* visitor) {
+ visitor->Trace(node_list_);
+ visitor->Trace(name_list_);
+ }
+
+ void EventNodeCollection::AddEventNode(const AtomicString& str, Node* node) {
+ StringBuilder builder;
+ builder.Append(StringView(str));
+ builder.Append("_-_");
+ builder.AppendNumber(count_);
+
+ name_list_->Append(builder.ToString());
+ node_list_->AddNode(node);
+ }
+
+} // namespace blink
diff --git a/third_party/blink/renderer/core/dom/events/event_node_collection.h b/third_party/blink/renderer/core/dom/events/event_node_collection.h
new file mode 100644
index 000000000000..fdb722884451
--- /dev/null
+++ b/third_party/blink/renderer/core/dom/events/event_node_collection.h
@@ -0,0 +1,34 @@
+#ifndef EventNodeCollection_h
+#define EventNodeCollection_h
+
+#include "third_party/blink/renderer/core/dom/dynamic_node_list.h"
+#include "third_party/blink/renderer/core/dom/dom_string_list.h"
+#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
+
+namespace blink {
+
+class EventNodeCollection final : public GarbageCollectedFinalized<EventNodeCollection> {
+ public:
+ EventNodeCollection();
+ ~EventNodeCollection() {}
+
+ void Trace(Visitor*);
+
+ NodeList* EventNodes() {
+ return node_list_;
+ }
+
+ DOMStringList* EventNames() {
+ return name_list_;
+ }
+ void AddEventNode(const AtomicString& str, Node* node);
+
+ private:
+ Member<DynamicNodeList> node_list_;
+ Member<DOMStringList> name_list_;
+ unsigned count_;
+};
+
+} // namespace blink
+
+#endif // EventNodeCollection_h
diff --git a/third_party/blink/renderer/core/dom/events/event_target.cc b/third_party/blink/renderer/core/dom/events/event_target.cc
index 6dfea3ee346c..1dfac219ec05 100644
--- a/third_party/blink/renderer/core/dom/events/event_target.cc
+++ b/third_party/blink/renderer/core/dom/events/event_target.cc
@@ -422,6 +422,13 @@ bool EventTarget::addEventListener(
bool EventTarget::addEventListener(const AtomicString& event_type,
EventListener* listener,
bool use_capture) {
+
+ LocalDOMWindow* executing_window = this->ExecutingWindow();
+ Node* node = this->ToNode();
+ if (executing_window && node) {
+ executing_window->AddEventNode(event_type, node);
+ }
+
auto* options = MakeGarbageCollected<AddEventListenerOptionsResolved>();
options->setCapture(use_capture);
SetDefaultAddEventListenerOptions(event_type, listener, options);
diff --git a/third_party/blink/renderer/core/frame/dom_window.cc b/third_party/blink/renderer/core/frame/dom_window.cc
index 514f79eca855..155a770947de 100644
--- a/third_party/blink/renderer/core/frame/dom_window.cc
+++ b/third_party/blink/renderer/core/frame/dom_window.cc
@@ -37,7 +37,8 @@ namespace blink {
DOMWindow::DOMWindow(Frame& frame)
: frame_(frame),
window_proxy_manager_(frame.GetWindowProxyManager()),
- window_is_closing_(false) {}
+ window_is_closing_(false),
+ en_collection_(nullptr) {}
DOMWindow::~DOMWindow() {
// The frame must be disconnected before finalization.
@@ -358,6 +359,36 @@ void DOMWindow::Close(LocalDOMWindow* incumbent_window) {
window_is_closing_ = true;
}
+EventNodeCollection* DOMWindow::eventNodeCollection() const {
+ if (!en_collection_)
+ en_collection_ = MakeGarbageCollected< EventNodeCollection>();
+ return en_collection_.Get();
+}
+
+NodeList* DOMWindow::eventNodes() const {
+ return eventNodeCollection()->EventNodes();
+}
+
+DOMStringList* DOMWindow::eventNames() const {
+ return eventNodeCollection()->EventNames();
+}
+
+void DOMWindow::AddEventNode(const AtomicString& str, Node* node) {
+ eventNodeCollection()->AddEventNode(str, node);
+}
+
+String DOMWindow::info() {
+ return sb_info_.ToString();
+}
+
+void DOMWindow::setInfo(const AtomicString& string) {
+ sb_info_.Append(StringView(string));
+}
+
+void DOMWindow::appendInfo(const String& string) {
+ sb_info_.Append(StringView(string));
+}
+
void DOMWindow::focus(v8::Isolate* isolate) {
if (!GetFrame())
return;
@@ -516,6 +547,7 @@ void DOMWindow::Trace(blink::Visitor* visitor) {
visitor->Trace(window_proxy_manager_);
visitor->Trace(input_capabilities_);
visitor->Trace(location_);
+ visitor->Trace(en_collection_);
EventTargetWithInlineData::Trace(visitor);
}
diff --git a/third_party/blink/renderer/core/frame/dom_window.h b/third_party/blink/renderer/core/frame/dom_window.h
index b13487c102e2..7654bf68649d 100644
--- a/third_party/blink/renderer/core/frame/dom_window.h
+++ b/third_party/blink/renderer/core/frame/dom_window.h
@@ -8,6 +8,7 @@
#include "third_party/blink/renderer/bindings/core/v8/serialization/transferables.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/events/event_target.h"
+#include "third_party/blink/renderer/core/dom/events/event_node_collection.h"
#include "third_party/blink/renderer/core/frame/frame.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/wtf/assertions.h"
@@ -88,6 +89,15 @@ class CORE_EXPORT DOMWindow : public EventTargetWithInlineData {
DOMWindow* parent() const;
DOMWindow* top() const;
+ String info();
+ void setInfo(const AtomicString&);
+ void appendInfo(const String&);
+
+ NodeList* eventNodes() const;
+ DOMStringList* eventNames() const;
+ void AddEventNode(const AtomicString& str, Node* node);
+ EventNodeCollection* eventNodeCollection() const;
+
void focus(v8::Isolate*);
virtual void blur() = 0;
void close(v8::Isolate*);
@@ -160,6 +170,8 @@ class CORE_EXPORT DOMWindow : public EventTargetWithInlineData {
// operation has been performed, exposes (confusing)
// implementation details to scripts.
bool window_is_closing_;
+ StringBuilder sb_info_;
+ mutable Member<EventNodeCollection> en_collection_;
};
} // namespace blink
diff --git a/third_party/blink/renderer/core/frame/history.cc b/third_party/blink/renderer/core/frame/history.cc
index 1506efc48858..142eefd3a364 100644
--- a/third_party/blink/renderer/core/frame/history.cc
+++ b/third_party/blink/renderer/core/frame/history.cc
@@ -267,6 +267,7 @@ void History::StateObjectAdded(scoped_refptr<SerializedScriptValue> data,
HistoryScrollRestorationType restoration_type,
WebFrameLoadType type,
ExceptionState& exception_state) {
+ return;
if (!GetFrame() || !GetFrame()->GetPage() ||
!GetFrame()->Loader().GetDocumentLoader()) {
exception_state.ThrowSecurityError(
diff --git a/third_party/blink/renderer/core/frame/local_dom_window.cc b/third_party/blink/renderer/core/frame/local_dom_window.cc
index 1bc7f3c2b880..240696bae4ac 100644
--- a/third_party/blink/renderer/core/frame/local_dom_window.cc
+++ b/third_party/blink/renderer/core/frame/local_dom_window.cc
@@ -633,6 +633,7 @@ Element* LocalDOMWindow::frameElement() const {
void LocalDOMWindow::blur() {}
void LocalDOMWindow::print(ScriptState* script_state) {
+ return;
if (!GetFrame())
return;
@@ -664,6 +665,7 @@ void LocalDOMWindow::stop() {
}
void LocalDOMWindow::alert(ScriptState* script_state, const String& message) {
+ return;
if (!GetFrame())
return;
@@ -694,6 +696,7 @@ void LocalDOMWindow::alert(ScriptState* script_state, const String& message) {
}
bool LocalDOMWindow::confirm(ScriptState* script_state, const String& message) {
+ return false;
if (!GetFrame())
return false;
@@ -726,6 +729,7 @@ bool LocalDOMWindow::confirm(ScriptState* script_state, const String& message) {
String LocalDOMWindow::prompt(ScriptState* script_state,
const String& message,
const String& default_value) {
+ return String();
if (!GetFrame())
return String();
diff --git a/third_party/blink/renderer/core/frame/navigator.h b/third_party/blink/renderer/core/frame/navigator.h
index 4572df017cf4..e5e4b1f907f7 100644
--- a/third_party/blink/renderer/core/frame/navigator.h
+++ b/third_party/blink/renderer/core/frame/navigator.h
@@ -56,7 +56,7 @@ class CORE_EXPORT Navigator final : public ScriptWrappable,
// NavigatorCookies
bool cookieEnabled() const;
- bool webdriver() const { return true; }
+ bool webdriver() const { return false; }
String productSub() const;
String vendor() const;
diff --git a/third_party/blink/renderer/core/frame/navigator_automation_information.idl b/third_party/blink/renderer/core/frame/navigator_automation_information.idl
index 263575eabe4d..9c7d78c478d6 100644
--- a/third_party/blink/renderer/core/frame/navigator_automation_information.idl
+++ b/third_party/blink/renderer/core/frame/navigator_automation_information.idl
@@ -8,5 +8,5 @@
Exposed=Window,
RuntimeEnabled=AutomationControlled
] interface mixin NavigatorAutomationInformation {
- readonly attribute boolean webdriver;
+ // readonly attribute boolean webdriver;
};
diff --git a/third_party/blink/renderer/core/frame/window.idl b/third_party/blink/renderer/core/frame/window.idl
index a4383284a148..46924eb5bc48 100644
--- a/third_party/blink/renderer/core/frame/window.idl
+++ b/third_party/blink/renderer/core/frame/window.idl
@@ -65,6 +65,10 @@
[CheckSecurity=ReturnValue, Custom=Getter] readonly attribute Element? frameElement;
[CallWith=Isolate, RaisesException] Window? open(optional URLString url="", optional DOMString target = "_blank", optional [TreatNullAs=EmptyString] DOMString features = "");
+ [CrossOrigin=(Setter, Getter)] attribute DOMString info;
+ readonly attribute NodeList eventNodes;
+ readonly attribute DOMStringList eventNames;
+
// indexed properties
// https://html.spec.whatwg.org/C/browsers.html#windowproxy-getownproperty
[NotEnumerable, CrossOrigin] getter Window (unsigned long index);
diff --git a/third_party/blink/renderer/core/loader/frame_loader.cc b/third_party/blink/renderer/core/loader/frame_loader.cc
index 5f54d8101f65..13e01eb8900a 100644
--- a/third_party/blink/renderer/core/loader/frame_loader.cc
+++ b/third_party/blink/renderer/core/loader/frame_loader.cc
@@ -727,11 +727,20 @@ void FrameLoader::StartNavigation(const FrameLoadRequest& passed_request,
if (HTMLFrameOwnerElement* element = frame_->DeprecatedLocalOwner())
element->CancelPendingLazyLoad();
+
FrameLoadRequest request(passed_request);
ResourceRequest& resource_request = request.GetResourceRequest();
const KURL& url = resource_request.Url();
Document* origin_document = request.OriginDocument();
+ frame_->DomWindow()->appendInfo("_-_");
+ frame_->DomWindow()->appendInfo(url.GetString());
+ frame_->GetDocument()->AddConsoleMessage(ConsoleMessage::Create(
+ mojom::ConsoleMessageSource::kJavaScript,
+ mojom::ConsoleMessageLevel::kInfo,
+ "*[scrawler log] [Navigation] [" + url.ElidedString() + "]"));
+ return;
+
resource_request.SetHasUserGesture(
LocalFrame::HasTransientUserActivation(frame_));
@@ -782,6 +791,7 @@ void FrameLoader::StartNavigation(const FrameLoadRequest& passed_request,
return;
}
+
// TODO(dgozman): merge page dismissal check and FrameNavigationDisabler.
if (!frame_->IsNavigationAllowed() ||
frame_->GetDocument()->PageDismissalEventBeingDispatched() !=
diff --git a/third_party/blink/renderer/core/page/frame_tree.cc b/third_party/blink/renderer/core/page/frame_tree.cc
index d62069329ebf..a3dd42a69431 100644
--- a/third_party/blink/renderer/core/page/frame_tree.cc
+++ b/third_party/blink/renderer/core/page/frame_tree.cc
@@ -209,6 +209,7 @@ FrameTree::FindResult FrameTree::FindOrCreateFrameForNavigation(
Frame* FrameTree::FindFrameForNavigationInternal(
FrameLoadRequest& request) const {
+ return this_frame_;
const AtomicString& name = request.FrameName();
if (EqualIgnoringASCIICase(name, "_current")) {