Remove use of deprecated test methods (asynctTest/callbackDone/expectThrows). (issue 12221052)

9 views
Skip to first unread message

gr...@google.com

unread,
Feb 6, 2013, 5:19:49 PM2/6/13
to v...@google.com, revie...@dartlang.org
Reviewers: vsm,

Description:
Remove use of deprecated test methods
(asynctTest/callbackDone/expectThrows).

Please review this at https://codereview.chromium.org/12221052/

SVN Base: http://src.chromium.org/multivm/trunk/webkit/LayoutTests/dart/

Affected files:
M Multiscript.html
M dom/GeolocationTest.dart
M dom/Workers.dart
M security/cross-frame-access.html


Index: Multiscript.html
===================================================================
--- Multiscript.html (revision 1080)
+++ Multiscript.html (working copy)
@@ -12,10 +12,11 @@
import 'Multiscript.dart';
main() {
useHtmlConfiguration(true);
- asyncTest('Multiple script tags', 3, () {
+ test('Multiple script tags', () {
+ var callback = expectAsync0(() {}, count: 3);
addHandler('done', (msg) {
Expect.equals(msg['actual'], msg['expect']);
- callbackDone();
+ callback();
});
postMessage('start', {});
});
Index: dom/GeolocationTest.dart
===================================================================
--- dom/GeolocationTest.dart (revision 1080)
+++ dom/GeolocationTest.dart (working copy)
@@ -8,29 +8,27 @@

errorCallback(error) => Expect.fail('${error.code}: ${error.message}');

- asyncTest('geolocation.getCurrentPosition', 1, () {
+ test('geolocation.getCurrentPosition', () {
final geolocation = window.navigator.geolocation;

- geolocation.getCurrentPosition((posA) {
- window.setTimeout(() {
- geolocation.getCurrentPosition((posB) {
+ geolocation.getCurrentPosition(expectAsync1((posA) {
+ window.setTimeout(expectAsync0(() {
+ geolocation.getCurrentPosition(expectAsync1((posB) {
Expect.equals(posA.coords.longitude, posB.coords.longitude);
- callbackDone();
- }, errorCallback);
- }, 0);
- }, errorCallback);
+ )}, errorCallback);
+ }), 0);
+ }), errorCallback);
});

- asyncTest('geolocation.watchPosition', 1, () {
+ test('geolocation.watchPosition', () {
final geolocation = window.navigator.geolocation;

- geolocation.getCurrentPosition((posA) {
- window.setTimeout(() {
- geolocation.watchPosition((posB) {
+ geolocation.getCurrentPosition(expectAsync1((posA) {
+ window.setTimeout(expectAsync0(() {
+ geolocation.watchPosition(expectAsync1((posB) {
Expect.equals(posA.coords.longitude, posB.coords.longitude);
- callbackDone();
- }, errorCallback);
- }, 0);
- }, errorCallback);
+ )}, errorCallback);
+ )}, 0);
+ )}, errorCallback);
});
}
Index: dom/Workers.dart
===================================================================
--- dom/Workers.dart (revision 1080)
+++ dom/Workers.dart (working copy)
@@ -5,15 +5,14 @@
main() {
useHtmlConfiguration(true);

- asyncTest('Workers minimal', 1, () {
+ test('Workers minimal', 1, () {
// FIXME: once we decide how Workers and Dart go together, this may
become pure
// Dart test.
final worker = new Worker('resources/pong.js');
worker.onError.listen((error) => Expect.fail('error: $error'));
- worker.onMessage.listen((event) {
+ worker.onMessage.listen(expectAsync1((event) {
Expect.equals('I am fine, thank you.', event.data);
- callbackDone();
- });
+ }));
worker.postMessage('How do you do?');
});
}
Index: security/cross-frame-access.html
===================================================================
--- security/cross-frame-access.html (revision 1080)
+++ security/cross-frame-access.html (working copy)
@@ -15,8 +15,8 @@
final crossOriginIFrame = new Element.tag('iframe');
crossOriginIFrame.src = 'data:text/html, <p>test iframe</p>';

- asyncTest('WaitForFramesLoad', 2, () {
- frameLoaded(Event e) { callbackDone(); }
+ test('WaitForFramesLoad', () {
+ var frameLoaded = expectAsync1((Event e) { }, count:2);
sameOriginIFrame.onLoad.listen(frameLoaded);
document.body.nodes.add(sameOriginIFrame);
crossOriginIFrame.onLoad.listen(frameLoaded);
@@ -33,7 +33,7 @@
testHistory(crossOriginIFrame.contentWindow.history);
});

- asyncTest('Location', 2, () {
+ test('Location', () {
testLocation(sameOriginIFrame.contentWindow.location);
testLocation(crossOriginIFrame.contentWindow.location);
});
@@ -46,15 +46,16 @@

testWindow(WindowBase targetWindow) {
// Not allowed methods.
- expectThrow(() => targetWindow.alert('test'));
- expectThrow(() => targetWindow.onLoad.listen((Event e) {}));
- expectThrow(() => targetWindow.find('test', true, true, true, true,
true, true));
+ expect(() => targetWindow.alert('test'), throws);
+ expect(() => targetWindow.onLoad.listen((Event e) {}), throws);
+ expect(() =>
+ targetWindow.find('test', true, true, true, true, true, true),
throws);

// Not allowed properties.
- expectThrow(() => targetWindow.contentDocument);
- expectThrow(() => targetWindow.frameElement);
- expectThrow(() => targetWindow.localStorage);
- expectThrow(() => targetWindow.console);
+ expect(() => targetWindow.contentDocument, throws);
+ expect(() => targetWindow.frameElement, throws);
+ expect(() => targetWindow.localStorage, throws);
+ expect(() => targetWindow.console, throws);

// Allowed methods.
targetWindow.close();
@@ -67,13 +68,13 @@

testHistory(HistoryBase history) {
// Not allowed properties.
- expectThrow(() => history.length);
+ expect(() => history.length, throws);

// Not allowed methods.
window.history.pushState('test', 'test', 'test');
- expectThrow(() => history.pushState('test', 'test', 'test'));
+ expect(() => history.pushState('test', 'test', 'test'), throws);
window.history.replaceState('test', 'test', 'test');
- expectThrow(() => history.replaceState('test', 'test', 'test'));
+ expect(() => history.replaceState('test', 'test', 'test'), throws);

// Allowed method.
history.back();
@@ -83,27 +84,27 @@

testLocation(LocationBase location) {
// Not allowed properties.
- expectThrow(() => location.href);
- expectThrow(() => location.protocol);
- expectThrow(() => location.host = 'test');
- expectThrow(() => location.origin);
+ expect(() => location.href, throws);
+ expect(() => location.protocol, throws);
+ expect(() => location.host = 'test', throws);
+ expect(() => location.origin, throws);

// Not allowed methods.
- expectThrow(() => location.assign('http://www.webkit.org'));
- expectThrow(() => location.reload());
- expectThrow(() => location.getParameter('test'));
+ expect(() => location.assign('http://www.webkit.org'), throws);
+ expect(() => location.reload(), throws);
+ expect(() => location.getParameter('test'), throws);

// Allowed properties.
- window.onMessage.listen((Event e) {
+ window.onMessage.listen(expectAsync1((Event e) {
expect(e.data, equals('navigated'));
- window.setTimeout(callbackDone, 0);
- });
+ window.setTimeout(expectAsync0((){}), 0);
+ )});
location.href = 'data:text/html,
<script>parent.postMessage("navigated", "*")<${"/script>"}';
}

testIFrameElement(IFrameElement iframe) {
- expectThrow(() => iframe.contentDocument);
- expectThrow(() => iframe.getSVGDocument());
+ expect(() => iframe.contentDocument, throws);
+ expect(() => iframe.getSVGDocument(), throws);
}
</script>



v...@google.com

unread,
Feb 6, 2013, 5:26:57 PM2/6/13
to gr...@google.com, revie...@dartlang.org

gr...@google.com

unread,
Feb 6, 2013, 6:09:09 PM2/6/13
to v...@google.com, revie...@dartlang.org
PTAL. I found some errors. I haven't been able to get them to run but used
the
editor to check the syntax.

https://codereview.chromium.org/12221052/

v...@google.com

unread,
Feb 6, 2013, 6:14:45 PM2/6/13
to gr...@google.com, revie...@dartlang.org

mar...@chromium.org

unread,
Feb 7, 2013, 12:32:57 PM2/7/13
to gr...@google.com, v...@google.com, revie...@dartlang.org
On 2013/02/06 23:14:45, vsm wrote:
> lgtm

FTR, multivm is not supported by the CQ.

https://codereview.chromium.org/12221052/

gr...@google.com

unread,
Feb 7, 2013, 1:05:00 PM2/7/13
to v...@google.com, revie...@dartlang.org

Vijay Menon

unread,
Feb 7, 2013, 1:50:20 PM2/7/13
to Graham Wheeler, Vijay Menon, revie...@dartlang.org
Still an error in cross-frame-access.html:

FAIL
1	ERROR	Expectation: WaitForFramesLoad. Callback called more times than expected (4 > 2).
2	PASS	Expectation: Window.
3	PASS	Expectation: History.
4	ERROR	Expectation: Location. Callback called more times than expected (2 > 1).
5	PASS	Expectation: IFrameElement.
Total 3 passed, 0 failed 2 errors


On Thu, Feb 7, 2013 at 10:05 AM, <gr...@google.com> wrote:
PTAL

https://codereview.chromium.org/12221052/

Reply all
Reply to author
Forward
0 new messages