Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1538)

Unified Diff: third_party/WebKit/Source/web/tests/LinkElementLoadingTest.cpp

Issue 2173413002: Add a test for canceling a pending stylesheet loading of a link element (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/web.gypi » ('j') | third_party/WebKit/Source/web/web.gypi » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/tests/LinkElementLoadingTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/LinkElementLoadingTest.cpp b/third_party/WebKit/Source/web/tests/LinkElementLoadingTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..647eb6ca24c46cfe0ca0f81820842781d37764e3
--- /dev/null
+++ b/third_party/WebKit/Source/web/tests/LinkElementLoadingTest.cpp
@@ -0,0 +1,42 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/dom/Document.h"
+#include "core/html/HTMLLinkElement.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "web/tests/sim/SimRequest.h"
+#include "web/tests/sim/SimTest.h"
+
+namespace blink {
+
+class LinkElementLoadingTest : public SimTest {
+};
+
+TEST_F(LinkElementLoadingTest, ShouldCancelLoadingStyleSheetIfLinkElementIsDisconnected)
+{
+ SimRequest mainResource("https://example.com/test.html", "text/html");
+ SimRequest cssResource("https://example.com/test.css", "text/css");
+
+ loadURL("https://example.com/test.html");
+
+ mainResource.start();
+ mainResource.write("<!DOCTYPE html><link id=link rel=stylesheet href=test.css>");
+
+ // Sheet is streaming in, but not ready yet.
+ cssResource.start();
+
+ // Remove a link element from a document
+ HTMLLinkElement* link = toHTMLLinkElement(document().getElementById("link"));
+ EXPECT_NE(nullptr, link);
+ link->remove();
+
+ // Finish the load.
+ cssResource.complete();
+ mainResource.finish();
+
+ // Link element's sheet loading should be canceled.
+ EXPECT_EQ(nullptr, link->sheet());
+}
+
+} // namespace blink
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/web.gypi » ('j') | third_party/WebKit/Source/web/web.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698