Title: [144622] trunk
- Revision
- 144622
- Author
- [email protected]
- Date
- 2013-03-04 05:34:47 -0800 (Mon, 04 Mar 2013)
Log Message
Web Inspector: Adding new rules broken if a <style> tag is added to document dynamically
https://bugs.webkit.org/show_bug.cgi?id=111299
Reviewed by Pavel Feldman.
Source/WebCore:
The CSSStyleSheet instance should be retrieved directly from the HTMLStyleElement just created,
not from the document.styleSheets list.
Test: inspector/styles/add-new-rule-with-style-after-body.html
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::viaInspectorStyleSheet):
LayoutTests:
* inspector/styles/add-new-rule-with-style-after-body-expected.txt: Added.
* inspector/styles/add-new-rule-with-style-after-body.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (144621 => 144622)
--- trunk/LayoutTests/ChangeLog 2013-03-04 13:15:26 UTC (rev 144621)
+++ trunk/LayoutTests/ChangeLog 2013-03-04 13:34:47 UTC (rev 144622)
@@ -1,3 +1,13 @@
+2013-03-04 Alexander Pavlov <[email protected]>
+
+ Web Inspector: Adding new rules broken if a <style> tag is added to document dynamically
+ https://bugs.webkit.org/show_bug.cgi?id=111299
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/styles/add-new-rule-with-style-after-body-expected.txt: Added.
+ * inspector/styles/add-new-rule-with-style-after-body.html: Added.
+
2013-03-04 Kinuko Yasuda <[email protected]>
[Chromium] Unreviewed, removing failure test expectations for passing softwarecompositing tests.
Added: trunk/LayoutTests/inspector/styles/add-new-rule-with-style-after-body-expected.txt (0 => 144622)
--- trunk/LayoutTests/inspector/styles/add-new-rule-with-style-after-body-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/styles/add-new-rule-with-style-after-body-expected.txt 2013-03-04 13:34:47 UTC (rev 144622)
@@ -0,0 +1,20 @@
+Tests that adding a new rule works when there is a STYLE element after BODY. TIMEOUT SHOULD NOT OCCUR! Bug 111299
+
+Text
+After adding new rule:
+[expanded]
+element.style { ()
+font-size: 12px;
+
+[expanded] [no-affect]
+inspected { (inspector-stylesheet:1)
+color: maroon;
+: ;
+
+======== Matched CSS Rules ========
+[expanded]
+div { (user agent stylesheet)
+display: block;
+
+
+
Added: trunk/LayoutTests/inspector/styles/add-new-rule-with-style-after-body.html (0 => 144622)
--- trunk/LayoutTests/inspector/styles/add-new-rule-with-style-after-body.html (rev 0)
+++ trunk/LayoutTests/inspector/styles/add-new-rule-with-style-after-body.html 2013-03-04 13:34:47 UTC (rev 144622)
@@ -0,0 +1,67 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+function addStyle()
+{
+ var style = document.createElement("style");
+ document.documentElement.appendChild(style);
+ style.sheet.insertRule("foo {display: none;}", 0);
+}
+
+function test()
+{
+ WebInspector.showPanel("elements");
+ InspectorTest.evaluateInPage("addStyle()", step0);
+
+ function step0()
+ {
+ InspectorTest.selectNodeAndWaitForStyles("inspected", step1);
+ }
+
+ var treeElement;
+ var hasResourceChanged;
+
+ function step1()
+ {
+ // Click "Add new rule".
+ document.getElementById("add-style-button-test-id").click();
+ var section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][2];
+ section._selectorElement.textContent = "inspected";
+ section._selectorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
+ InspectorTest.runAfterPendingDispatches(step2);
+ }
+
+ function step2()
+ {
+ var section = WebInspector.panels.elements.sidebarPanes.styles.sections[0][2];
+ var newProperty = section.addNewBlankProperty();
+ newProperty.startEditing();
+ newProperty.nameElement.textContent = "color";
+ newProperty.nameElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
+ newProperty.valueElement.textContent = "maroon";
+ newProperty.valueElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
+ InspectorTest.waitForStyles("inspected", step3);
+ }
+
+ function step3()
+ {
+ InspectorTest.addResult("After adding new rule:");
+ InspectorTest.dumpSelectedElementStyles(true, false, true);
+ InspectorTest.completeTest();
+ }
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Tests that adding a new rule works when there is a STYLE element after BODY. TIMEOUT SHOULD NOT OCCUR! <a href="" 111299</a>
+</p>
+
+<div id="inspected" style="font-size: 12px">Text</div>
+
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (144621 => 144622)
--- trunk/Source/WebCore/ChangeLog 2013-03-04 13:15:26 UTC (rev 144621)
+++ trunk/Source/WebCore/ChangeLog 2013-03-04 13:34:47 UTC (rev 144622)
@@ -1,3 +1,18 @@
+2013-03-04 Alexander Pavlov <[email protected]>
+
+ Web Inspector: Adding new rules broken if a <style> tag is added to document dynamically
+ https://bugs.webkit.org/show_bug.cgi?id=111299
+
+ Reviewed by Pavel Feldman.
+
+ The CSSStyleSheet instance should be retrieved directly from the HTMLStyleElement just created,
+ not from the document.styleSheets list.
+
+ Test: inspector/styles/add-new-rule-with-style-after-body.html
+
+ * inspector/InspectorCSSAgent.cpp:
+ (WebCore::InspectorCSSAgent::viaInspectorStyleSheet):
+
2013-03-04 Ilya Tikhonovsky <[email protected]>
Web Inspector: Unreviewed. Fix for closure type annotations.
Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (144621 => 144622)
--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2013-03-04 13:15:26 UTC (rev 144621)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2013-03-04 13:34:47 UTC (rev 144622)
@@ -40,6 +40,7 @@
#include "DOMWindow.h"
#include "ExceptionCodePlaceholder.h"
#include "HTMLHeadElement.h"
+#include "HTMLStyleElement.h"
#include "InspectorDOMAgent.h"
#include "InspectorHistory.h"
#include "InspectorState.h"
@@ -1080,11 +1081,16 @@
}
if (ec)
return 0;
- StyleSheetList* styleSheets = document->styleSheets();
- StyleSheet* styleSheet = styleSheets->item(styleSheets->length() - 1);
- if (!styleSheet || !styleSheet->isCSSStyleSheet())
+
+ HTMLElement* htmlElement = toHTMLElement(styleElement.get());
+ if (!htmlElement || !htmlElement->hasTagName(HTMLNames::styleTag))
return 0;
- CSSStyleSheet* cssStyleSheet = static_cast<CSSStyleSheet*>(styleSheet);
+
+ HTMLStyleElement* htmlStyleElement = static_cast<HTMLStyleElement*>(htmlElement);
+ CSSStyleSheet* cssStyleSheet = htmlStyleElement->sheet();
+ if (!cssStyleSheet)
+ return 0;
+
String id = String::number(m_lastStyleSheetId++);
inspectorStyleSheet = InspectorStyleSheet::create(m_domAgent->pageAgent(), id, cssStyleSheet, TypeBuilder::CSS::StyleSheetOrigin::Inspector, InspectorDOMAgent::documentURLString(document), this);
m_idToInspectorStyleSheet.set(id, inspectorStyleSheet);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes