Diff
Modified: trunk/LayoutTests/ChangeLog (200064 => 200065)
--- trunk/LayoutTests/ChangeLog 2016-04-26 00:44:45 UTC (rev 200064)
+++ trunk/LayoutTests/ChangeLog 2016-04-26 00:44:52 UTC (rev 200065)
@@ -1,3 +1,23 @@
+2016-04-25 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: React.js JSXTransformer produces bogus error locations
+ https://bugs.webkit.org/show_bug.cgi?id=150010
+ <rdar://problem/23062233>
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/model/frame-extra-scripts-expected.txt: Added.
+ * inspector/model/frame-extra-scripts.html: Added.
+ Add a test for a WebInspector.Frame's extraScripts list.
+
+ * inspector/model/stack-trace-expected.txt:
+ Update output that we correctly get the sourceURL of the inner script.
+
+ * inspector/model/script-resource-relationship-expected.txt
+ * inspector/model/script-resource-relationship.html
+ Add a test for a dynamicallyAddedScriptElement.
+ Remove debug logging.
+
2016-04-25 Ryan Haddad <[email protected]>
Skip fast/layers/no-clipping-overflow-hidden-added-after-transform.html on mac-wk1 debug
Added: trunk/LayoutTests/inspector/model/frame-extra-scripts-expected.txt (0 => 200065)
--- trunk/LayoutTests/inspector/model/frame-extra-scripts-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/model/frame-extra-scripts-expected.txt 2016-04-26 00:44:52 UTC (rev 200065)
@@ -0,0 +1,13 @@
+CONSOLE MESSAGE: line 1: dynamically added script element
+WebInspector.Frame.extraScripts.
+
+
+== Running test suite: WebInspector.Frame.extraScripts
+-- Running test case: FrameHasNoExtraScriptsYet
+PASS: Main frame should have no dynamic scripts.
+
+-- Running test case: AddExtraScript
+PASS: ExtraScriptAdded event fired.
+PASS: Script should identify as dynamic.
+PASS: Main frame should have 1 dynamic script.
+
Added: trunk/LayoutTests/inspector/model/frame-extra-scripts.html (0 => 200065)
--- trunk/LayoutTests/inspector/model/frame-extra-scripts.html (rev 0)
+++ trunk/LayoutTests/inspector/model/frame-extra-scripts.html 2016-04-26 00:44:52 UTC (rev 200065)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function triggerAddScriptElement() {
+ let script = document.createElement("script");
+ script.text = "console.log('dynamically added script element');";
+ document.body.appendChild(script);
+}
+
+function test()
+{
+ let suite = InspectorTest.createAsyncSuite("WebInspector.Frame.extraScripts");
+
+ suite.addTestCase({
+ name: "FrameHasNoExtraScriptsYet",
+ description: "No extra scripts yet.",
+ test: (resolve, reject) => {
+ let mainFrame = WebInspector.frameResourceManager.mainFrame;
+ InspectorTest.expectThat(mainFrame.extraScripts.length === 0, "Main frame should have no dynamic scripts.");
+ resolve();
+ }
+ });
+
+ suite.addTestCase({
+ name: "AddExtraScript",
+ description: "Add extra script.",
+ test: (resolve, reject) => {
+ WebInspector.frameResourceManager.mainFrame.singleFireEventListener(WebInspector.Frame.Event.ExtraScriptAdded, (event) => {
+ InspectorTest.pass("ExtraScriptAdded event fired.");
+ InspectorTest.expectThat(event.data.script.dynamicallyAddedScriptElement, "Script should identify as dynamic.");
+ });
+
+ InspectorTest.evaluateInPage("triggerAddScriptElement()", () => {
+ let mainFrame = WebInspector.frameResourceManager.mainFrame;
+ InspectorTest.expectThat(mainFrame.extraScripts.length === 1, "Main frame should have 1 dynamic script.");
+ resolve();
+ });
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>WebInspector.Frame.extraScripts.</p>
+</body>
+</html>
Modified: trunk/LayoutTests/inspector/model/script-resource-relationship-expected.txt (200064 => 200065)
--- trunk/LayoutTests/inspector/model/script-resource-relationship-expected.txt 2016-04-26 00:44:45 UTC (rev 200064)
+++ trunk/LayoutTests/inspector/model/script-resource-relationship-expected.txt 2016-04-26 00:44:52 UTC (rev 200065)
@@ -25,6 +25,11 @@
PASS: Script should not be associated with a Resource.
PASS: Script should have a sourceURL.
+-- Running test case: DynamicallyAddedScriptElementNoResource
+PASS: Script was added.
+PASS: Script should identify as a dynamically added script element.
+PASS: Script should not be associated when a resource.
+
-- Running test case: DocumentWithInlineScripts
PASS: Main Resource should have 4 scripts.
PASS: Inline script 1 does not have a sourceURL.
Modified: trunk/LayoutTests/inspector/model/script-resource-relationship.html (200064 => 200065)
--- trunk/LayoutTests/inspector/model/script-resource-relationship.html 2016-04-26 00:44:45 UTC (rev 200064)
+++ trunk/LayoutTests/inspector/model/script-resource-relationship.html 2016-04-26 00:44:52 UTC (rev 200065)
@@ -26,13 +26,16 @@
eval("//# sourceURL=script-only.js\n1+1");
}
+function triggerScriptElement() {
+ let script = document.createElement("script");
+ script.text = "//# sourceURL=dynamically-added-script-element.js\n1+1";
+ document.body.appendChild(script);
+}
+
function test()
{
let suite = InspectorTest.createAsyncSuite("WebInspector.Script and WebInspector.Resource relationship");
- InspectorTest.dumpActivityToSystemConsole = true;
- InspectorBackend.dumpInspectorProtocolMessages = true;
-
function validateNormalRelationship(resource, script) {
InspectorTest.expectThat(resource.url ="" script.url, "Resource and Script have the same URL.");
InspectorTest.expectThat(resource.scripts.length === 1, "Resource should be related to one script.");
@@ -133,6 +136,29 @@
});
suite.addTestCase({
+ name: "DynamicallyAddedScriptElementNoResource",
+ description: "A dynamically added script element has no resource.",
+ test: (resolve, reject) => {
+ WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, scriptListener);
+
+ function scriptListener(event) {
+ if (event.data.script.sourceURL !== "dynamically-added-script-element.js")
+ return;
+ InspectorTest.pass("Script was added.");
+ let script = event.data.script;
+
+ InspectorTest.expectThat(script.dynamicallyAddedScriptElement, "Script should identify as a dynamically added script element.");
+ InspectorTest.expectThat(script.resource === null, "Script should not be associated when a resource.");
+
+ WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, scriptListener, null);
+ resolve();
+ }
+
+ InspectorTest.evaluateInPage("triggerScriptElement()");
+ }
+ });
+
+ suite.addTestCase({
name: "DocumentWithInlineScripts",
description: "A document resource may be associated with multiple inline scripts.",
test: (resolve, reject) => {
Modified: trunk/LayoutTests/inspector/model/stack-trace-expected.txt (200064 => 200065)
--- trunk/LayoutTests/inspector/model/stack-trace-expected.txt 2016-04-26 00:44:45 UTC (rev 200064)
+++ trunk/LayoutTests/inspector/model/stack-trace-expected.txt 2016-04-26 00:44:52 UTC (rev 200065)
@@ -12,7 +12,7 @@
1: foo (Anonymous Script 1 (line 1)) - nativeCode (false) programCode (false)
2: Eval Code (Anonymous Script 1 (line 1)) - nativeCode (false) programCode (true)
3: eval - nativeCode (true) programCode (false)
- 4: Global Code (stack-trace.html:2) - nativeCode (false) programCode (true)
+ 4: Global Code (inline-script.js:2) - nativeCode (false) programCode (true)
5: appendChild - nativeCode (true) programCode (false)
6: triggerConsoleMessage (stack-trace.html:9) - nativeCode (false) programCode (false)
7: Eval Code (Anonymous Script 2 (line 1)) - nativeCode (false) programCode (true)
Modified: trunk/Source/WebInspectorUI/ChangeLog (200064 => 200065)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-04-26 00:44:45 UTC (rev 200064)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-04-26 00:44:52 UTC (rev 200065)
@@ -1,5 +1,48 @@
2016-04-25 Joseph Pecoraro <[email protected]>
+ Web Inspector: React.js JSXTransformer produces bogus error locations
+ https://bugs.webkit.org/show_bug.cgi?id=150010
+ <rdar://problem/23062233>
+
+ Reviewed by Timothy Hatcher.
+
+ Show dynamically added <script> elements added to a frame as resources.
+ For cases where the scripts had source map resources or error messages
+ we have a root from which to associate them to.
+
+ * Localizations/en.lproj/localizedStrings.js:
+ "Script Element %d" tree element title.
+
+ * UserInterface/Models/Frame.js:
+ (WebInspector.Frame.prototype.commitProvisionalLoad):
+ (WebInspector.Frame.prototype.get extraScripts):
+ (WebInspector.Frame.prototype.addExtraScript):
+ Have a frame keep a list of its extra scripts.
+
+ * UserInterface/Models/Script.js:
+ (WebInspector.Script):
+ (WebInspector.Script.prototype.get displayName):
+ (WebInspector.Script.prototype.get dynamicallyAddedScriptElement):
+ Identify dynamically added script elements and associate them
+ with the frame, instead of the frame's main resource.
+
+ * UserInterface/Views/FrameTreeElement.js:
+ (WebInspector.FrameTreeElement.prototype.onpopulate):
+ (WebInspector.FrameTreeElement.prototype._extraScriptAdded):
+ Show named / source mapped dynamic script elements under a frame.
+
+ * UserInterface/Views/ResourceSidebarPanel.js:
+ (WebInspector.ResourceSidebarPanel.prototype._scriptWasAdded):
+ Dynamically added script element Scripts will be added by the frame that
+ owns them.
+
+ * UserInterface/Views/ScriptTreeElement.js:
+ (WebInspector.ScriptTreeElement):
+ Don't include a subtitle for dynamicallyAddedScriptElement, details match
+ the frame that owns them.
+
+2016-04-25 Joseph Pecoraro <[email protected]>
+
Web Inspector: Line error widget showed in the wrong resource
https://bugs.webkit.org/show_bug.cgi?id=150009
<rdar://problem/23062199>
Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (200064 => 200065)
--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2016-04-26 00:44:45 UTC (rev 200064)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2016-04-26 00:44:52 UTC (rev 200065)
@@ -607,6 +607,7 @@
localizedStrings["Scope"] = "Scope";
localizedStrings["Scope Chain"] = "Scope Chain";
localizedStrings["Script"] = "Script";
+localizedStrings["Script Element %d"] = "Script Element %d";
localizedStrings["Script Evaluated"] = "Script Evaluated";
localizedStrings["Scripts"] = "Scripts";
localizedStrings["Scroll Into View"] = "Scroll Into View";
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Frame.js (200064 => 200065)
--- trunk/Source/WebInspectorUI/UserInterface/Models/Frame.js 2016-04-26 00:44:45 UTC (rev 200064)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Frame.js 2016-04-26 00:44:52 UTC (rev 200065)
@@ -38,6 +38,7 @@
this._resourceCollection = new WebInspector.ResourceCollection;
this._provisionalResourceCollection = new WebInspector.ResourceCollection;
+ this._extraScripts = [];
this._childFrames = [];
this._childFrameIdentifierMap = {};
@@ -127,6 +128,7 @@
this._resourceCollection = this._provisionalResourceCollection;
this._provisionalResourceCollection = new WebInspector.ResourceCollection;
+ this._extraScripts = [];
this.clearExecutionContexts(true);
this.clearProvisionalLoad(true);
@@ -437,6 +439,18 @@
this.dispatchEventToListeners(WebInspector.Frame.Event.AllResourcesRemoved);
}
+ get extraScripts()
+ {
+ return this._extraScripts;
+ }
+
+ addExtraScript(script)
+ {
+ this._extraScripts.push(script);
+
+ this.dispatchEventToListeners(WebInspector.Frame.Event.ExtraScriptAdded, {script});
+ }
+
saveIdentityToCookie(cookie)
{
cookie[WebInspector.Frame.MainResourceURLCookieKey] = this.mainResource.url.hash;
@@ -495,6 +509,7 @@
ResourceWasAdded: "frame-resource-was-added",
ResourceWasRemoved: "frame-resource-was-removed",
AllResourcesRemoved: "frame-all-resources-removed",
+ ExtraScriptAdded: "frame-extra-script-added",
ChildFrameWasAdded: "frame-child-frame-was-added",
ChildFrameWasRemoved: "frame-child-frame-was-removed",
AllChildFramesRemoved: "frame-all-child-frames-removed",
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Script.js (200064 => 200065)
--- trunk/Source/WebInspectorUI/UserInterface/Models/Script.js 2016-04-26 00:44:45 UTC (rev 200064)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Script.js 2016-04-26 00:44:52 UTC (rev 200065)
@@ -36,21 +36,33 @@
this._range = range || null;
this._url = url || null;
this._sourceURL = sourceURL || null;
+ this._sourceMappingURL = sourceMapURL || null;
this._injected = injected || false;
+ this._dynamicallyAddedScriptElement = false;
+ this._scriptSyntaxTree = null;
this._resource = this._resolveResource();
- if (this._resource)
+
+ // If this Script was a dynamically added <script> to a Document,
+ // do not associate with the Document resource, instead associate
+ // with the frame as a dynamic script.
+ if (this._resource && this._resource.type === WebInspector.Resource.Type.Document && !this._range.startLine && !this._range.startColumn) {
+ console.assert(this._resource.isMainResource());
+ let documentResource = this._resource;
+ this._resource = null;
+ this._dynamicallyAddedScriptElement = true;
+ documentResource.parentFrame.addExtraScript(this);
+ this._dynamicallyAddedScriptElementNumber = documentResource.parentFrame.extraScripts.length;
+ } else if (this._resource)
this._resource.associateWithScript(this);
- if (sourceMapURL)
- WebInspector.sourceMapManager.downloadSourceMap(sourceMapURL, this._url, this);
-
if (isWebInspectorConsoleEvaluationScript(this._sourceURL)) {
// Assign a unique number to the script object so it will stay the same.
this._uniqueDisplayNameNumber = this.constructor._nextUniqueConsoleDisplayNameNumber++;
}
- this._scriptSyntaxTree = null;
+ if (this._sourceMappingURL)
+ WebInspector.sourceMapManager.downloadSourceMap(this._sourceMappingURL, this._url, this);
}
// Static
@@ -83,6 +95,11 @@
return this._sourceURL;
}
+ get sourceMappingURL()
+ {
+ return this._sourceMappingURL;
+ }
+
get urlComponents()
{
if (!this._urlComponents)
@@ -97,7 +114,7 @@
get displayName()
{
- if (this._url)
+ if (this._url && !this._dynamicallyAddedScriptElement)
return WebInspector.displayNameForURL(this._url, this.urlComponents);
if (isWebInspectorConsoleEvaluationScript(this._sourceURL)) {
@@ -111,6 +128,9 @@
return WebInspector.displayNameForURL(this._sourceURL, this._sourceURLComponents);
}
+ if (this._dynamicallyAddedScriptElement)
+ return WebInspector.UIString("Script Element %d").format(this._dynamicallyAddedScriptElementNumber);
+
// Assign a unique number to the script object so it will stay the same.
if (!this._uniqueDisplayNameNumber)
this._uniqueDisplayNameNumber = this.constructor._nextUniqueDisplayNameNumber++;
@@ -135,6 +155,11 @@
return this._injected;
}
+ get dynamicallyAddedScriptElement()
+ {
+ return this._dynamicallyAddedScriptElement;
+ }
+
get anonymous()
{
return !this._resource && !this._url && !this._sourceURL;
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js (200064 => 200065)
--- trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js 2016-04-26 00:44:45 UTC (rev 200064)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js 2016-04-26 00:44:52 UTC (rev 200065)
@@ -38,6 +38,7 @@
frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
frame.addEventListener(WebInspector.Frame.Event.ResourceWasAdded, this._resourceWasAdded, this);
frame.addEventListener(WebInspector.Frame.Event.ResourceWasRemoved, this._resourceWasRemoved, this);
+ frame.addEventListener(WebInspector.Frame.Event.ExtraScriptAdded, this._extraScriptAdded, this);
frame.addEventListener(WebInspector.Frame.Event.ChildFrameWasAdded, this._childFrameWasAdded, this);
frame.addEventListener(WebInspector.Frame.Event.ChildFrameWasRemoved, this._childFrameWasRemoved, this);
@@ -52,17 +53,23 @@
this.folderSettingsKey = this._frame.url.hash;
this.registerFolderizeSettings("frames", WebInspector.UIString("Frames"),
- function(representedObject) { return representedObject instanceof WebInspector.Frame; },
- function() { return this.frame.childFrames.length; }.bind(this),
+ (representedObject) => representedObject instanceof WebInspector.Frame,
+ () => this.frame.childFrames.length,
WebInspector.FrameTreeElement
);
this.registerFolderizeSettings("flows", WebInspector.UIString("Flows"),
- function(representedObject) { return representedObject instanceof WebInspector.ContentFlow; },
- function() { return this.frame.domTree.flowsCount; }.bind(this),
+ (representedObject) => representedObject instanceof WebInspector.ContentFlow,
+ () => this.frame.domTree.flowsCount,
WebInspector.ContentFlowTreeElement
);
+ this.registerFolderizeSettings("extra-scripts", WebInspector.UIString("Extra Scripts"),
+ (representedObject) => representedObject instanceof WebInspector.Script && representedObject.dynamicallyAddedScriptElement,
+ () => this.frame.extraScripts.length,
+ WebInspector.ScriptTreeElement
+ );
+
function makeValidateCallback(resourceType) {
return function(representedObject) {
return representedObject instanceof WebInspector.Resource && representedObject.type === resourceType;
@@ -189,6 +196,10 @@
for (var flowKey in flowMap)
this.addChildForRepresentedObject(flowMap[flowKey]);
+ for (let extraScript of this._frame.extraScripts) {
+ if (extraScript.sourceURL || extraScript.sourceMappingURL)
+ this.addChildForRepresentedObject(extraScript);
+ }
}
onexpand()
@@ -240,6 +251,13 @@
this.removeChildForRepresentedObject(event.data.resource);
}
+ _extraScriptAdded(event)
+ {
+ let extraScript = event.data.script;
+ if (extraScript.sourceURL || extraScript.sourceMappingURL)
+ this.addRepresentedObjectToNewChildQueue(extraScript);
+ }
+
_childFrameWasAdded(event)
{
this.addRepresentedObjectToNewChildQueue(event.data.childFrame);
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js (200064 => 200065)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js 2016-04-26 00:44:45 UTC (rev 200064)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js 2016-04-26 00:44:52 UTC (rev 200065)
@@ -279,7 +279,7 @@
return;
// If the script URL matches a resource we can assume it is part of that resource and does not need added.
- if (script.resource)
+ if (script.resource || script.dynamicallyAddedScriptElement)
return;
var insertIntoTopLevel = false;
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTreeElement.js (200064 => 200065)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTreeElement.js 2016-04-26 00:44:45 UTC (rev 200064)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTreeElement.js 2016-04-26 00:44:52 UTC (rev 200065)
@@ -33,7 +33,7 @@
this.mainTitle = script.displayName;
- if (script.url) {
+ if (script.url && !script.dynamicallyAddedScriptElement) {
// Show the host as the subtitle if it is different from the main title.
var subtitle = WebInspector.displayNameForHost(script.urlComponents.host);
this.subtitle = this.mainTitle !== subtitle ? subtitle : null;