Web Inspector: LayoutTests/inspector should not have localStorage side effects
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Nov 2014 02:19:12 +0000 (02:19 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Nov 2014 02:19:12 +0000 (02:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138895

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2014-11-19
Reviewed by Brian Burg.

When running inspector tests, do not restore/save WebInspector.Settings
to localStorage, as that will cause side effects. Instead each Setting
will be initialized with its default value and can be modified during
the run of the test.

* UserInterface/Base/Test.js:
(WebInspector.loaded):
Name the setting to match the normal setting name now that persistence
is not an issue.

* UserInterface/Models/Setting.js:
(WebInspector.Setting.prototype.get value):
(WebInspector.Setting.prototype.set value):
Do not restore/save when in tests.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176376 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Test.js
Source/WebInspectorUI/UserInterface/Models/Setting.js

index 491cc7a..2a6535c 100644 (file)
@@ -1,5 +1,27 @@
 2014-11-19  Joseph Pecoraro  <pecoraro@apple.com>
 
 2014-11-19  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: LayoutTests/inspector should not have localStorage side effects
+        https://bugs.webkit.org/show_bug.cgi?id=138895
+
+        Reviewed by Brian Burg.
+
+        When running inspector tests, do not restore/save WebInspector.Settings
+        to localStorage, as that will cause side effects. Instead each Setting
+        will be initialized with its default value and can be modified during
+        the run of the test.
+
+        * UserInterface/Base/Test.js:
+        (WebInspector.loaded):
+        Name the setting to match the normal setting name now that persistence
+        is not an issue.
+
+        * UserInterface/Models/Setting.js:
+        (WebInspector.Setting.prototype.get value):
+        (WebInspector.Setting.prototype.set value):
+        Do not restore/save when in tests.
+
+2014-11-19  Joseph Pecoraro  <pecoraro@apple.com>
+
         Web Inspector: JSContext inspection Resource search does not work
         https://bugs.webkit.org/show_bug.cgi?id=131252
 
         Web Inspector: JSContext inspection Resource search does not work
         https://bugs.webkit.org/show_bug.cgi?id=131252
 
index afb2349..2ebf13f 100644 (file)
@@ -67,7 +67,8 @@ WebInspector.loaded = function()
     // Perform one-time tasks.
     WebInspector.CSSCompletions.requestCSSNameCompletions();
 
     // Perform one-time tasks.
     WebInspector.CSSCompletions.requestCSSNameCompletions();
 
-    this.showShadowDOMSetting = new WebInspector.Setting("test-show-shadow-dom", true);
+    // Global settings.
+    this.showShadowDOMSetting = new WebInspector.Setting("show-shadow-dom", true);
 }
 
 WebInspector.contentLoaded = function()
 }
 
 WebInspector.contentLoaded = function()
index d13b54d..b5e6537 100644 (file)
@@ -62,7 +62,7 @@ WebInspector.Setting.prototype = {
         // Make a copy of the default value so changes to object values don't modify the default value.
         this._value = JSON.parse(JSON.stringify(this._defaultValue));
 
         // Make a copy of the default value so changes to object values don't modify the default value.
         this._value = JSON.parse(JSON.stringify(this._defaultValue));
 
-        if (window.localStorage && this._localStorageKey in window.localStorage) {
+        if (!window.InspectorTest && window.localStorage && this._localStorageKey in window.localStorage) {
             try {
                 this._value = JSON.parse(window.localStorage[this._localStorageKey]);
             } catch(e) {
             try {
                 this._value = JSON.parse(window.localStorage[this._localStorageKey]);
             } catch(e) {
@@ -77,7 +77,7 @@ WebInspector.Setting.prototype = {
     {
         this._value = value;
 
     {
         this._value = value;
 
-        if (window.localStorage) {
+        if (!window.InspectorTest && window.localStorage) {
             try {
                 // Use Object.shallowEqual to properly compare objects.
                 if (Object.shallowEqual(this._value, this._defaultValue))
             try {
                 // Use Object.shallowEqual to properly compare objects.
                 if (Object.shallowEqual(this._value, this._defaultValue))