Got rid of the internal copies of webview attributes.
Webview attributes are now only stored in one location (in the webview node), so that all the code needed to sync up the copies could be removed (and was).
Also reworked the behavior of the |allowtransparency| and |autosize| to be both consistent with each other and more intuitive in general (they are both treated like booleans now). I updated the tests to reflect this new behavior.
Review URL: https://codereview.chromium.org/698973003
Cr-Commit-Position: refs/heads/master@{#302661}
diff --git a/chrome/browser/apps/web_view_browsertest.cc b/chrome/browser/apps/web_view_browsertest.cc
index ead6ef9..4f61be5 100644
--- a/chrome/browser/apps/web_view_browsertest.cc
+++ b/chrome/browser/apps/web_view_browsertest.cc
@@ -950,8 +950,10 @@
TestHelper("testCannotMutateEventName", "web_view/shim", NO_TEST_SERVER);
}
-IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestPartitionRaisesException) {
- TestHelper("testPartitionRaisesException", "web_view/shim", NO_TEST_SERVER);
+IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestPartitionChangeAfterNavigation) {
+ TestHelper("testPartitionChangeAfterNavigation",
+ "web_view/shim",
+ NO_TEST_SERVER);
}
IN_PROC_BROWSER_TEST_F(WebViewTest,
diff --git a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js
index dee4cc68..8a98077 100644
--- a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js
+++ b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js
@@ -97,20 +97,28 @@
// Tests begin.
-// This test verifies that the allowtransparency property cannot be changed
-// once set. The attribute can only be deleted.
+// This test verifies that the allowtransparency property is interpreted as true
+// if it exists (regardless of its value), and can be removed by setting it to
+// to anything false.
function testAllowTransparencyAttribute() {
var webview = document.createElement('webview');
webview.src = 'data:text/html,webview test';
+ embedder.test.assertFalse(webview.hasAttribute('allowtransparency'));
+ embedder.test.assertFalse(webview.allowtransparency);
webview.allowtransparency = true;
webview.addEventListener('loadstop', function(e) {
embedder.test.assertTrue(webview.hasAttribute('allowtransparency'));
- webview.allowtransparency = false;
embedder.test.assertTrue(webview.allowtransparency);
- embedder.test.assertTrue(webview.hasAttribute('allowtransparency'));
- webview.removeAttribute('allowtransparency');
+ webview.allowtransparency = false;
+ embedder.test.assertFalse(webview.hasAttribute('allowtransparency'));
embedder.test.assertFalse(webview.allowtransparency);
+ webview.allowtransparency = '';
+ embedder.test.assertFalse(webview.hasAttribute('allowtransparency'));
+ embedder.test.assertFalse(webview.allowtransparency);
+ webview.allowtransparency = 'some string';
+ embedder.test.assertTrue(webview.hasAttribute('allowtransparency'));
+ embedder.test.assertTrue(webview.allowtransparency);
embedder.test.succeed();
});
@@ -616,7 +624,7 @@
// Current expected behavior is that the second event listener will still
// fire without crashing.
function testDestroyOnEventListener() {
- var webview = util.createWebViewTagInDOM(arguments.callee.name);
+ var webview = document.createElement('webview');
var url = 'data:text/html,<body>Destroy test</body>';
var loadCommitCount = 0;
@@ -647,13 +655,14 @@
loadCommitCommon(e);
});
webview.setAttribute('src', url);
+ document.body.appendChild(webview);
}
// This test registers two event listeners on a same event (loadcommit).
// Each of the listener tries to change some properties on the event param,
// which should not be possible.
function testCannotMutateEventName() {
- var webview = util.createWebViewTagInDOM(arguments.callee.name);
+ var webview = document.createElement('webview');
var url = 'data:text/html,<body>Two</body>';
var loadCommitACalled = false;
@@ -695,23 +704,20 @@
webview.addEventListener('loadcommit', onLoadCommitA);
webview.addEventListener('loadcommit', onLoadCommitB);
webview.setAttribute('src', url);
+ document.body.appendChild(webview);
}
-// This test verifies that setting the partition attribute after the src has
-// been set raises an exception.
-function testPartitionRaisesException() {
+// This test verifies that the partion attribute cannot be changed after the src
+// has been set.
+function testPartitionChangeAfterNavigation() {
var webview = document.createElement('webview');
var partitionAttribute = arguments.callee.name;
webview.setAttribute('partition', partitionAttribute);
var loadstopHandler = function(e) {
- try {
- webview.partition = 'illegal';
- embedder.test.fail();
- } catch (e) {
- embedder.test.assertEq(partitionAttribute, webview.partition);
- embedder.test.succeed();
- }
+ webview.partition = 'illegal';
+ embedder.test.assertEq(partitionAttribute, webview.partition);
+ embedder.test.succeed();
};
webview.addEventListener('loadstop', loadstopHandler);
@@ -1999,7 +2005,7 @@
'testLoadProgressEvent': testLoadProgressEvent,
'testDestroyOnEventListener': testDestroyOnEventListener,
'testCannotMutateEventName': testCannotMutateEventName,
- 'testPartitionRaisesException': testPartitionRaisesException,
+ 'testPartitionChangeAfterNavigation': testPartitionChangeAfterNavigation,
'testPartitionRemovalAfterNavigationFails':
testPartitionRemovalAfterNavigationFails,
'testExecuteScriptFail': testExecuteScriptFail,
diff --git a/extensions/browser/guest_view/web_view/web_view_apitest.cc b/extensions/browser/guest_view/web_view/web_view_apitest.cc
index 6f052ab4..0502ecb 100644
--- a/extensions/browser/guest_view/web_view/web_view_apitest.cc
+++ b/extensions/browser/guest_view/web_view/web_view_apitest.cc
@@ -615,8 +615,8 @@
RunTest("testOnEventProperties", "web_view/apitest");
}
-IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestPartitionRaisesException) {
- RunTest("testPartitionRaisesException", "web_view/apitest");
+IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestPartitionChangeAfterNavigation) {
+ RunTest("testPartitionChangeAfterNavigation", "web_view/apitest");
}
IN_PROC_BROWSER_TEST_F(WebViewAPITest,
diff --git a/extensions/renderer/resources/guest_view/web_view.js b/extensions/renderer/resources/guest_view/web_view.js
index 8405e384..31f4b531 100644
--- a/extensions/renderer/resources/guest_view/web_view.js
+++ b/extensions/renderer/resources/guest_view/web_view.js
@@ -34,7 +34,6 @@
this.beforeFirstNavigation = true;
this.contentWindow = null;
- this.validPartitionId = true;
// Used to save some state upon deferred attachment.
// If <object> bindings is not available, we defer attachment.
// This state contains whether or not the attachment request was for
@@ -82,7 +81,6 @@
GuestViewInternal.destroyGuest(this.guestInstanceId);
this.guestInstanceId = undefined;
this.beforeFirstNavigation = true;
- this.validPartitionId = true;
this.attributes[WebViewConstants.ATTRIBUTE_PARTITION].validPartitionId =
true;
this.contentWindow = null;
@@ -129,14 +127,12 @@
WebView.prototype.setupAutoSizeProperties = function() {
$Array.forEach(AUTO_SIZE_ATTRIBUTES, function(attributeName) {
- this.attributes[attributeName].setValue(
- this.webviewNode.getAttribute(attributeName));
Object.defineProperty(this.webviewNode, attributeName, {
get: function() {
return this.attributes[attributeName].getValue();
}.bind(this),
set: function(value) {
- this.webviewNode.setAttribute(attributeName, value);
+ this.attributes[attributeName].setValue(value);
}.bind(this),
enumerable: true
});
@@ -153,9 +149,8 @@
getValue();
}.bind(this),
set: function(value) {
- this.webviewNode.setAttribute(
- WebViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY,
- value);
+ this.attributes[WebViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY].
+ setValue(value);
}.bind(this),
enumerable: true
});
@@ -179,7 +174,7 @@
return this.attributes[WebViewConstants.ATTRIBUTE_NAME].getValue();
}.bind(this),
set: function(value) {
- this.webviewNode.setAttribute(WebViewConstants.ATTRIBUTE_NAME, value);
+ this.attributes[WebViewConstants.ATTRIBUTE_NAME].setValue(value);
}.bind(this),
enumerable: true
});
@@ -190,25 +185,17 @@
return this.attributes[WebViewConstants.ATTRIBUTE_PARTITION].getValue();
}.bind(this),
set: function(value) {
- var result = this.attributes[WebViewConstants.ATTRIBUTE_PARTITION].
- setValue(value);
- if (result.error) {
- throw result.error;
- }
- this.webviewNode.setAttribute(WebViewConstants.ATTRIBUTE_PARTITION,
- value);
+ this.attributes[WebViewConstants.ATTRIBUTE_PARTITION].setValue(value);
}.bind(this),
enumerable: true
});
- this.attributes[WebViewConstants.ATTRIBUTE_SRC].setValue(
- this.webviewNode.getAttribute(WebViewConstants.ATTRIBUTE_SRC));
Object.defineProperty(this.webviewNode, WebViewConstants.ATTRIBUTE_SRC, {
get: function() {
return this.attributes[WebViewConstants.ATTRIBUTE_SRC].getValue();
}.bind(this),
set: function(value) {
- this.webviewNode.setAttribute(WebViewConstants.ATTRIBUTE_SRC, value);
+ this.attributes[WebViewConstants.ATTRIBUTE_SRC].setValue(value);
}.bind(this),
enumerable: true
});
@@ -223,7 +210,7 @@
this.srcAndPartitionObserver = new MutationObserver(function(mutations) {
$Array.forEach(mutations, function(mutation) {
var oldValue = mutation.oldValue;
- var newValue = this.webviewNode.getAttribute(mutation.attributeName);
+ var newValue = this.attributes[mutation.attributeName].getValue();
if (oldValue != newValue) {
return;
}
@@ -246,17 +233,22 @@
// attribute, if necessary. See BrowserPlugin::UpdateDOMAttribute for more
// details.
WebView.prototype.handleWebviewAttributeMutation =
- function(name, oldValue, newValue) {
- if (AUTO_SIZE_ATTRIBUTES.indexOf(name) > -1) {
- this.attributes[name].setValue(newValue);
+ function(attributeName, oldValue, newValue) {
+ // Certain changes (such as internally-initiated changes) to attributes should
+ // not be handled normally.
+ if (this.attributes[attributeName] &&
+ this.attributes[attributeName].ignoreNextMutation) {
+ this.attributes[attributeName].ignoreNextMutation = false;
+ return;
+ }
+
+ if (AUTO_SIZE_ATTRIBUTES.indexOf(attributeName) > -1) {
if (!this.guestInstanceId) {
return;
}
- // Convert autosize attribute to boolean.
- var autosize = this.webviewNode.hasAttribute(
- WebViewConstants.ATTRIBUTE_AUTOSIZE);
GuestViewInternal.setAutoSize(this.guestInstanceId, {
- 'enableAutoSize': autosize,
+ 'enableAutoSize': this.attributes[WebViewConstants.ATTRIBUTE_AUTOSIZE].
+ getValue(),
'min': {
'width': parseInt(this.
attributes[WebViewConstants.ATTRIBUTE_MINWIDTH].getValue() || 0),
@@ -271,19 +263,13 @@
}
});
return;
- } else if (name == WebViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY) {
+ } else if (attributeName == WebViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY) {
// We treat null attribute (attribute removed) and the empty string as
// one case.
oldValue = oldValue || '';
newValue = newValue || '';
- if (oldValue === newValue) {
- return;
- }
- this.attributes[WebViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY].
- setValue(newValue != '');
-
- if (!this.guestInstanceId) {
+ if (oldValue === newValue || !this.guestInstanceId) {
return;
}
@@ -292,7 +278,7 @@
this.attributes[WebViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY].
getValue());
return;
- } else if (name == WebViewConstants.ATTRIBUTE_NAME) {
+ } else if (attributeName == WebViewConstants.ATTRIBUTE_NAME) {
// We treat null attribute (attribute removed) and the empty string as
// one case.
oldValue = oldValue || '';
@@ -301,19 +287,19 @@
if (oldValue === newValue) {
return;
}
- this.attributes[WebViewConstants.ATTRIBUTE_NAME].setValue(newValue);
+
if (!this.guestInstanceId) {
return;
}
WebViewInternal.setName(this.guestInstanceId, newValue);
return;
- } else if (name == WebViewConstants.ATTRIBUTE_SRC) {
+ } else if (attributeName == WebViewConstants.ATTRIBUTE_SRC) {
// We treat null attribute (attribute removed) and the empty string as
// one case.
oldValue = oldValue || '';
newValue = newValue || '';
// Once we have navigated, we don't allow clearing the src attribute.
- // Once <webview> enters a navigated state, it cannot be return back to a
+ // Once <webview> enters a navigated state, it cannot return to a
// placeholder state.
if (newValue == '' && oldValue != '') {
// src attribute changes normally initiate a navigation. We suppress
@@ -323,28 +309,23 @@
this.webviewNode.setAttribute(WebViewConstants.ATTRIBUTE_SRC, oldValue);
return;
}
- this.attributes[WebViewConstants.ATTRIBUTE_SRC].setValue(newValue);
+
if (this.ignoreNextSrcAttributeChange) {
// Don't allow the src mutation observer to see this change.
this.srcAndPartitionObserver.takeRecords();
this.ignoreNextSrcAttributeChange = false;
return;
}
- var result = {};
- this.parseSrcAttribute(result);
-
- if (result.error) {
- throw result.error;
- }
- } else if (name == WebViewConstants.ATTRIBUTE_PARTITION) {
- // Note that throwing error here won't synchronously propagate.
- this.attributes[WebViewConstants.ATTRIBUTE_PARTITION].setValue(newValue);
+ this.parseSrcAttribute();
+ } else if (attributeName == WebViewConstants.ATTRIBUTE_PARTITION) {
+ this.attributes[WebViewConstants.ATTRIBUTE_PARTITION].handleMutation(
+ oldValue, newValue);
}
};
WebView.prototype.handleBrowserPluginAttributeMutation =
- function(name, oldValue, newValue) {
- if (name == WebViewConstants.ATTRIBUTE_INTERNALINSTANCEID &&
+ function(attributeName, oldValue, newValue) {
+ if (attributeName == WebViewConstants.ATTRIBUTE_INTERNALINSTANCEID &&
!oldValue && !!newValue) {
this.browserPluginNode.removeAttribute(
WebViewConstants.ATTRIBUTE_INTERNALINSTANCEID);
@@ -417,7 +398,7 @@
minHeight = maxHeight;
}
- if (!this.webviewNode.hasAttribute(WebViewConstants.ATTRIBUTE_AUTOSIZE) ||
+ if (!this.attributes[WebViewConstants.ATTRIBUTE_AUTOSIZE].getValue() ||
(newWidth >= minWidth &&
newWidth <= maxWidth &&
newHeight >= minHeight &&
@@ -439,15 +420,9 @@
return !this.beforeFirstNavigation;
};
-WebView.prototype.parseSrcAttribute = function(result) {
- if (!this.attributes[WebViewConstants.ATTRIBUTE_PARTITION].validPartitionId) {
- result.error = WebViewConstants.ERROR_MSG_INVALID_PARTITION_ATTRIBUTE;
- return;
- }
- this.attributes[WebViewConstants.ATTRIBUTE_SRC].setValue(
- this.webviewNode.getAttribute(WebViewConstants.ATTRIBUTE_SRC));
-
- if (!this.attributes[WebViewConstants.ATTRIBUTE_SRC].getValue()) {
+WebView.prototype.parseSrcAttribute = function() {
+ if (!this.attributes[WebViewConstants.ATTRIBUTE_PARTITION].validPartitionId ||
+ !this.attributes[WebViewConstants.ATTRIBUTE_SRC].getValue()) {
return;
}
@@ -469,22 +444,16 @@
if (!this.elementAttached) {
return;
}
- var attributeValue = this.webviewNode.getAttribute(
- WebViewConstants.ATTRIBUTE_PARTITION);
- var result = this.attributes[WebViewConstants.ATTRIBUTE_PARTITION].setValue(
- attributeValue);
- this.parseSrcAttribute(result);
+ this.parseSrcAttribute();
};
WebView.prototype.createGuest = function() {
if (this.pendingGuestCreation) {
return;
}
- var storagePartitionId =
- this.webviewNode.getAttribute(WebViewConstants.ATTRIBUTE_PARTITION) ||
- this.webviewNode[WebViewConstants.ATTRIBUTE_PARTITION];
var params = {
- 'storagePartitionId': storagePartitionId
+ 'storagePartitionId': this.attributes[
+ WebViewConstants.ATTRIBUTE_PARTITION].getValue()
};
GuestViewInternal.createGuest(
'webview',
@@ -502,13 +471,11 @@
};
WebView.prototype.onFrameNameChanged = function(name) {
- this.attributes[WebViewConstants.ATTRIBUTE_NAME].setValue(name || '');
- if (this.attributes[WebViewConstants.ATTRIBUTE_NAME].getValue() === '') {
+ name = name || '';
+ if (name === '') {
this.webviewNode.removeAttribute(WebViewConstants.ATTRIBUTE_NAME);
} else {
- this.webviewNode.setAttribute(
- WebViewConstants.ATTRIBUTE_NAME,
- this.attributes[WebViewConstants.ATTRIBUTE_NAME].getValue());
+ this.attributes[WebViewConstants.ATTRIBUTE_NAME].setValue(name);
}
};
@@ -543,7 +510,7 @@
this.currentEntryIndex = currentEntryIndex;
this.entryCount = entryCount;
this.processId = processId;
- var oldValue = this.webviewNode.getAttribute(WebViewConstants.ATTRIBUTE_SRC);
+ var oldValue = this.attributes[WebViewConstants.ATTRIBUTE_SRC].getValue();
var newValue = url;
if (isTopLevel && (oldValue != newValue)) {
// Touching the src attribute triggers a navigation. To avoid
@@ -555,8 +522,6 @@
};
WebView.prototype.onAttach = function(storagePartitionId) {
- this.webviewNode.setAttribute(WebViewConstants.ATTRIBUTE_PARTITION,
- storagePartitionId);
this.attributes[WebViewConstants.ATTRIBUTE_PARTITION].setValue(
storagePartitionId);
};
@@ -564,9 +529,8 @@
WebView.prototype.buildAttachParams = function(isNewWindow) {
var params = {
'allowtransparency': this.attributes[
- WebViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY].getValue() || false,
- 'autosize': this.webviewNode.hasAttribute(
- WebViewConstants.ATTRIBUTE_AUTOSIZE),
+ WebViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY].getValue(),
+ 'autosize': this.attributes[WebViewConstants.ATTRIBUTE_AUTOSIZE].getValue(),
'instanceId': this.viewInstanceId,
'maxheight': parseInt(this.attributes[WebViewConstants.ATTRIBUTE_MAXHEIGHT].
getValue() || 0),
@@ -590,7 +554,7 @@
};
WebView.prototype.attachWindow = function(guestInstanceId,
- isNewWindow) {
+ isNewWindow) {
this.guestInstanceId = guestInstanceId;
var params = this.buildAttachParams(isNewWindow);
diff --git a/extensions/renderer/resources/guest_view/web_view_attributes.js b/extensions/renderer/resources/guest_view/web_view_attributes.js
index 56f38740..1e02b89 100644
--- a/extensions/renderer/resources/guest_view/web_view_attributes.js
+++ b/extensions/renderer/resources/guest_view/web_view_attributes.js
@@ -13,63 +13,69 @@
// Default implementation of a WebView attribute.
function WebViewAttribute(name, webViewImpl) {
this.name = name;
- this.value = '';
this.webViewImpl = webViewImpl;
+ this.ignoreNextMutation = false;
}
+// Retrieves and returns the attribute's value.
WebViewAttribute.prototype.getValue = function() {
- return this.value || '';
+ return this.webViewImpl.webviewNode.getAttribute(this.name) || '';
};
+// Sets the attribute's value.
WebViewAttribute.prototype.setValue = function(value) {
- this.value = value;
+ this.webViewImpl.webviewNode.setAttribute(this.name, value || '');
};
+// Called when the attribute's value changes.
+WebViewAttribute.prototype.handleMutation = function() {}
+
+// Attribute specifying whether transparency is allowed in the webview.
+function BooleanAttribute(name, webViewImpl) {
+ WebViewAttribute.call(this, name, webViewImpl);
+}
+
+BooleanAttribute.prototype = new WebViewAttribute();
+
+BooleanAttribute.prototype.getValue = function() {
+ // This attribute is treated as a boolean, and is retrieved as such.
+ return this.webViewImpl.webviewNode.hasAttribute(this.name);
+}
+
+BooleanAttribute.prototype.setValue = function(value) {
+ if (!value) {
+ this.webViewImpl.webviewNode.removeAttribute(this.name);
+ } else {
+ this.webViewImpl.webviewNode.setAttribute(this.name, '');
+ }
+}
+
// Attribute representing the state of the storage partition.
function Partition(webViewImpl) {
+ WebViewAttribute.call(this,
+ WebViewConstants.ATTRIBUTE_PARTITION,
+ webViewImpl);
this.validPartitionId = true;
- this.persistStorage = false;
- this.storagePartitionId = '';
- this.webViewImpl = webViewImpl;
}
-Partition.prototype = new WebViewAttribute(
- WebViewConstants.ATTRIBUTE_PARTITION);
+Partition.prototype = new WebViewAttribute();
-Partition.prototype.getValue = function() {
- if (!this.validPartitionId) {
- return '';
- }
- return (this.persistStorage ? 'persist:' : '') + this.storagePartitionId;
-};
+Partition.prototype.handleMutation = function(oldValue, newValue) {
+ newValue = newValue || '';
-Partition.prototype.setValue = function(value) {
- var result = {};
- var hasNavigated = !this.webViewImpl.beforeFirstNavigation;
- if (hasNavigated) {
- result.error = WebViewConstants.ERROR_MSG_ALREADY_NAVIGATED;
- return result;
+ // The partition cannot change if the webview has already navigated.
+ if (!this.webViewImpl.beforeFirstNavigation) {
+ window.console.error(WebViewConstants.ERROR_MSG_ALREADY_NAVIGATED);
+ this.ignoreNextMutation = true;
+ this.webViewImpl.webviewNode.setAttribute(this.name, oldValue);
+ return;
}
- if (!value) {
- value = '';
+ if (newValue == 'persist:') {
+ this.validPartitionId = false;
+ window.console.error(
+ WebViewConstants.ERROR_MSG_INVALID_PARTITION_ATTRIBUTE);
}
-
- var LEN = 'persist:'.length;
- if (value.substr(0, LEN) == 'persist:') {
- value = value.substr(LEN);
- if (!value) {
- this.validPartitionId = false;
- result.error = WebViewConstants.ERROR_MSG_INVALID_PARTITION_ATTRIBUTE;
- return result;
- }
- this.persistStorage = true;
- } else {
- this.persistStorage = false;
- }
-
- this.storagePartitionId = value;
- return result;
-};
+}
// -----------------------------------------------------------------------------
@@ -79,12 +85,14 @@
// Initialize the attributes with special behavior (and custom attribute
// objects).
+ this.attributes[WebViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY] =
+ new BooleanAttribute(WebViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY, this);
+ this.attributes[WebViewConstants.ATTRIBUTE_AUTOSIZE] =
+ new BooleanAttribute(WebViewConstants.ATTRIBUTE_AUTOSIZE, this);
this.attributes[WebViewConstants.ATTRIBUTE_PARTITION] = new Partition(this);
// Initialize the remaining attributes, which have default behavior.
- var defaultAttributes = [WebViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY,
- WebViewConstants.ATTRIBUTE_AUTOSIZE,
- WebViewConstants.ATTRIBUTE_MAXHEIGHT,
+ var defaultAttributes = [WebViewConstants.ATTRIBUTE_MAXHEIGHT,
WebViewConstants.ATTRIBUTE_MAXWIDTH,
WebViewConstants.ATTRIBUTE_MINHEIGHT,
WebViewConstants.ATTRIBUTE_MINWIDTH,
diff --git a/extensions/test/data/web_view/apitest/main.js b/extensions/test/data/web_view/apitest/main.js
index 1287723..2c8d15f 100644
--- a/extensions/test/data/web_view/apitest/main.js
+++ b/extensions/test/data/web_view/apitest/main.js
@@ -71,15 +71,22 @@
function testAllowTransparencyAttribute() {
var webview = document.createElement('webview');
webview.src = 'data:text/html,webview test';
+ embedder.test.assertFalse(webview.hasAttribute('allowtransparency'));
+ embedder.test.assertFalse(webview.allowtransparency);
webview.allowtransparency = true;
webview.addEventListener('loadstop', function(e) {
embedder.test.assertTrue(webview.hasAttribute('allowtransparency'));
- webview.allowtransparency = false;
embedder.test.assertTrue(webview.allowtransparency);
- embedder.test.assertTrue(webview.hasAttribute('allowtransparency'));
- webview.removeAttribute('allowtransparency');
+ webview.allowtransparency = false;
+ embedder.test.assertFalse(webview.hasAttribute('allowtransparency'));
embedder.test.assertFalse(webview.allowtransparency);
+ webview.allowtransparency = '';
+ embedder.test.assertFalse(webview.hasAttribute('allowtransparency'));
+ embedder.test.assertFalse(webview.allowtransparency);
+ webview.allowtransparency = 'some string';
+ embedder.test.assertTrue(webview.hasAttribute('allowtransparency'));
+ embedder.test.assertTrue(webview.allowtransparency);
embedder.test.succeed();
});
@@ -1282,21 +1289,17 @@
document.body.appendChild(webview);
}
-// This test verifies that setting the partition attribute after the src has
-// been set raises an exception.
-function testPartitionRaisesException() {
+// This test verifies that the partion attribute cannot be changed after the src
+// has been set.
+function testPartitionChangeAfterNavigation() {
var webview = document.createElement('webview');
var partitionAttribute = arguments.callee.name;
webview.setAttribute('partition', partitionAttribute);
var loadstopHandler = function(e) {
- try {
- webview.partition = 'illegal';
- embedder.test.fail();
- } catch (e) {
- embedder.test.assertEq(partitionAttribute, webview.partition);
- embedder.test.succeed();
- }
+ webview.partition = 'illegal';
+ embedder.test.assertEq(partitionAttribute, webview.partition);
+ embedder.test.succeed();
};
webview.addEventListener('loadstop', loadstopHandler);
@@ -1707,7 +1710,7 @@
'testNewWindowNoReferrerLink': testNewWindowNoReferrerLink,
'testNewWindowTwoListeners': testNewWindowTwoListeners,
'testOnEventProperties': testOnEventProperties,
- 'testPartitionRaisesException': testPartitionRaisesException,
+ 'testPartitionChangeAfterNavigation': testPartitionChangeAfterNavigation,
'testPartitionRemovalAfterNavigationFails':
testPartitionRemovalAfterNavigationFails,
'testReassignSrcAttribute': testReassignSrcAttribute,